© 2026 schoolict.net (Ruwan Mangala Suraweera)
9.7 Database Queries: Criteria and Sortingදත්ත සමුදාය Queries: නිර්ණායක සහ වර්ග කිරීම
G.C.E. O/L Grade 10 ICT · Lesson 9G.C.E. O/L ICT · 10 ශ්රේණිය · පාඩම 9
In this videoමේ වීඩියෝවේ
- A query selects fields and records; Run (!) shows them.Query fields සහ records තෝරයි; Run (!) පෙන්වයි.
- Criteria operators: = > < >= <= <>.Criteria operators: = > < >= <= <>.
- Like “A*” and Between 600 And 1000.Like “A*” සහ Between 600 And 1000.
- AND on the same row; OR on different rows.AND එකම පේළියේ; OR වෙනස් පේළිවල.
- Sort Ascending or Descending; SQL SELECT is behind it.Ascending හෝ Descending sort; පිටුපස SQL SELECT.
Notesසටහන්
A query asks the database a question, such as ‘Which students scored 75 or more in ICT?’ and shows only the matching records, in the order you want. In this note you will build queries in Query Design (no code needed) by choosing fields, typing criteria with = > < >= <= <>, Like, Between, And/Or, and sorting ascending or descending. Every result below comes from our school database.Query එකක් දත්ත සමුදායෙන් ප්රශ්නයක් අසයි, උදා ‘ICT හි 75 හෝ ඊට වැඩි ලකුණු ලැබූ සිසුන් කවුද?’ සහ ගැළපෙන records පමණක් ඔබට අවශ්ය පිළිවෙලට පෙන්වයි. මෙම සටහනේ Query Design (කේත අවශ්ය නැත) හි fields තෝරා, = > < >= <= <>, Like, Between, And/Or සමඟ criteria type කර, ආරෝහණ හෝ අවරෝහණ ලෙස sort කරමින් queries ගොඩනගමු. පහත සෑම ප්රතිඵලයක්ම අපගේ පාසල් දත්ත සමුදායෙනි.
1. Creating a query in Design View1. Design View හි query එකක් සෑදීම
- Access: Create › Query Design › add tblStudent. Base: Queries › Create Query in Design View.Access: Create › Query Design › tblStudent add කරන්න. Base: Queries › Create Query in Design View.
- Double-click (or drag) fields into the grid: AdmNo, StudentName, ICTMarks.Fields grid එකට double-click (හෝ drag): AdmNo, StudentName, ICTMarks.
- Type the condition in the Criteria row; choose Sort; tick/untick Show.Criteria පේළියේ කොන්දේසිය type කරන්න; Sort තෝරන්න; Show tick/untick කරන්න.
- Click Run (!) to see the result in Datasheet View; save as qryHighICT.ප්රතිඵලය Datasheet View හි බැලීමට Run (!) click කරන්න; qryHighICT ලෙස save කරන්න.
| Grid rowGrid පේළිය | Meaningඅර්ථය |
|---|---|
| FieldField | The field to useභාවිත කරන field එක |
| TableTable | Table it comes fromපැමිණෙන table එක |
| SortSort | Ascending (A→Z, 0→9) / Descending (Z→A, 9→0)Ascending (A→Z, 0→9) / Descending (Z→A, 9→0) |
| ShowShow | Tick to display the field in the resultප්රතිඵලයේ පෙන්වීමට tick |
| CriteriaCriteria | Condition records must meetRecords සපුරාලිය යුතු කොන්දේසිය |
| oror | An alternative condition (OR)විකල්ප කොන්දේසියක් (OR) |
2. Comparison operators2. සංසන්දන operators
| OperatorOperator | Meaningඅර්ථය | Exampleඋදාහරණය |
|---|---|---|
| == | equal toසමාන | “10A” (text in quotes)“10A” (text in quotes) |
| >> | greater thanවැඩි | >70>70 |
| << | less thanඅඩු | <50<50 |
| >=>= | greater than or equalවැඩි හෝ සමාන | >=75>=75 |
| <=<= | less than or equalඅඩු හෝ සමාන | <=1000<=1000 |
| <><> | not equalඅසමාන | <>“Novel”<>“Novel” |
Query qryHighICT – criteria ICTMarks >=75, sorted Descending: 4 students.qryHighICT query – criteria ICTMarks >=75, Descending: සිසුන් 4.
| AdmNoAdmNo | StudentNameStudentName | ICTMarksICTMarks |
|---|---|---|
| 2410324103 | Nethmi FernandoNethmi Fernando | 9191 |
| 2410924109 | Sanduni RajapakshaSanduni Rajapaksha | 8888 |
| 2410124101 | Amaya PereraAmaya Perera | 8282 |
| 2410524105 | Ayesha FathimaAyesha Fathima | 7777 |
Query qry10A – criteria ClassID “10A”, sorted by StudentName Ascending: 4 students (Amaya Perera, Arun Kumar, Kavindu Silva, Sanduni Rajapaksha).qry10A query – criteria ClassID “10A”, StudentName අනුව Ascending: සිසුන් 4 (Amaya Perera, Arun Kumar, Kavindu Silva, Sanduni Rajapaksha).
| StudentNameStudentName | ClassIDClassID | ICTMarksICTMarks |
|---|---|---|
| Amaya PereraAmaya Perera | 10A10A | 8282 |
| Arun KumarArun Kumar | 10A10A | 5555 |
| Kavindu SilvaKavindu Silva | 10A10A | 6464 |
| Sanduni RajapakshaSanduni Rajapaksha | 10A10A | 8888 |
Query qryFail – ICTMarks <50, sorted Ascending: Tharindu Bandara, Ashen Jayasinghe.qryFail query – ICTMarks <50, Ascending: Tharindu Bandara, Ashen Jayasinghe.
| StudentNameStudentName | ICTMarksICTMarks |
|---|---|
| Tharindu BandaraTharindu Bandara | 3939 |
| Ashen JayasingheAshen Jayasinghe | 4848 |
Text and dates: text goes in quotes (“10A”); Access dates go between # (<#2010-06-01#). Query qryBorn finds 4 students born before 1 June 2010.පෙළ සහ දින: පෙළ උද්ධෘතවල (“10A”); Access දින # අතර (<#2010-06-01#). qryBorn query මගින් 2010 ජූනි 1 ට පෙර උපන් සිසුන් 4 ක් සොයයි.
| StudentNameStudentName | DateOfBirthDateOfBirth |
|---|---|
| Nethmi FernandoNethmi Fernando | 25/01/201025/01/2010 |
| Dilini WickramasingheDilini Wickramasinghe | 11/02/201011/02/2010 |
| Amaya PereraAmaya Perera | 14/03/201014/03/2010 |
| Ayesha FathimaAyesha Fathima | 30/05/201030/05/2010 |
3. Like and Between3. Like සහ Between
Like “A*” finds names starting with A (* = any characters, ? = one character). Result (4): Amaya Perera, Arun Kumar, Ashen Jayasinghe, Ayesha Fathima.Like “A*” A න් ආරම්භ වන නම් සොයයි (* = ඕනෑම අක්ෂර, ? = එක් අක්ෂරයක්). ප්රතිඵලය (4): Amaya Perera, Arun Kumar, Ashen Jayasinghe, Ayesha Fathima.
| AdmNoAdmNo | StudentNameStudentName |
|---|---|
| 2410124101 | Amaya PereraAmaya Perera |
| 2410624106 | Arun KumarArun Kumar |
| 2410424104 | Ashen JayasingheAshen Jayasinghe |
| 2410524105 | Ayesha FathimaAyesha Fathima |
Between 600 And 1000 on Price includes both ends (600 and 1000). 4 books, sorted by Price Ascending:Price මත Between 600 And 1000 අන්ත දෙකම ඇතුළත් (600 සහ 1000). පොත් 4 ක්, Price Ascending:
| BookIDBookID | TitleTitle | PricePrice |
|---|---|---|
| B005B005 | Amba YaluwoAmba Yaluwo | 600600 |
| B001B001 | Madol DoovaMadol Doova | 750750 |
| B002B002 | GamperaliyaGamperaliya | 950950 |
| B008B008 | Atlas of AsiaAtlas of Asia | 990990 |
4. And / Or4. And / Or
| StudentNameStudentName | ClassIDClassID | ICTMarksICTMarks |
|---|---|---|
| Nethmi FernandoNethmi Fernando | 10B10B | 9191 |
| Ayesha FathimaAyesha Fathima | 10B10B | 7777 |
| StudentNameStudentName | ClassIDClassID | PrefectPrefect |
|---|---|---|
| Amaya PereraAmaya Perera | 10A10A | YesYes |
| Ashen JayasingheAshen Jayasinghe | 10C10C | NoNo |
| Dilini WickramasingheDilini Wickramasinghe | 10C10C | YesYes |
| Malith HerathMalith Herath | 10C10C | NoNo |
| Nethmi FernandoNethmi Fernando | 10B10B | YesYes |
Not equal: Category <>“Novel” gives 5 books.අසමාන: Category <>“Novel” පොත් 5 ක් දෙයි.
| TitleTitle | CategoryCategory |
|---|---|
| Atlas of AsiaAtlas of Asia | ReferenceReference |
| Birds of Sri LankaBirds of Sri Lanka | ScienceScience |
| Python for BeginnersPython for Beginners | ComputingComputing |
| Sri Lanka School AtlasSri Lanka School Atlas | ReferenceReference |
| The Story of SigiriyaThe Story of Sigiriya | HistoryHistory |
Yes/No criteria: Returned = No lists the books not yet returned (4 loans).Yes/No criteria: Returned = No තවම ආපසු නොදුන් පොත් ලැයිස්තු කරයි (ණය 4).
| BorrowIDBorrowID | BookIDBookID | AdmNoAdmNo |
|---|---|---|
| 22 | B005B005 | 2410324103 |
| 33 | B004B004 | 2410124101 |
| 55 | B001B001 | 2410524105 |
| 66 | B006B006 | 2410924109 |
5. Extra (not required for O/L): SQL SELECT5. අමතර (O/L සඳහා අවශ්ය නැත): SQL SELECT
Behind every Query Design is SQL (Structured Query Language). In Access click View › SQL View to see it:සෑම Query Design එකක් පිටුපසම SQL (Structured Query Language) ඇත. Access හි View › SQL View click කර එය බලන්න:
| SQL (extra)SQL (අමතර) | Meaningඅර්ථය |
|---|---|
| SELECT AdmNo, StudentName, ICTMarksSELECT AdmNo, StudentName, ICTMarks | fields to showපෙන්වන fields |
| FROM tblStudentFROM tblStudent | the tabletable එක |
| WHERE ICTMarks >= 75WHERE ICTMarks >= 75 | criteriacriteria |
| ORDER BY ICTMarks DESC;ORDER BY ICTMarks DESC; | sort (ASC/DESC)sort (ASC/DESC) |
Key Wordsප්රධාන පද
Sample Q&Aආදර්ශ ප්රශ්න සහ පිළිතුරු
1What is a query?Query එකක් යනු කුමක්ද?
2Write criteria for ICT marks 75 or more.ICT ලකුණු 75 හෝ වැඩි සඳහා criteria ලියන්න.
3Write criteria for names starting with A.A න් ආරම්භ වන නම් සඳහා criteria ලියන්න.
4How is AND entered in the grid?Grid එකේ AND ඇතුළත් කරන්නේ කෙසේද?
5How is OR entered?OR ඇතුළත් කරන්නේ කෙසේද?
6What does unticking Show do?Show untick කිරීමෙන් කුමක් වේද?
MCQබහුවරණ ප්රශ්න
Choose the correct answer for each question.සෑම ප්රශ්නයකටම නිවැරදි පිළිතුර තෝරන්න.
1A query that lists ICTMarks >= 75 from tblStudent returns how many records?tblStudent න් ICTMarks >= 75 ලැයිස්තු කරන query එක records කීයක් දෙයිද?
✔ Correct!නිවැරදියි!✘ Not quite.වැරදියි. Correct answerනිවැරදි පිළිතුර: A
Nethmi Fernando, Sanduni Rajapaksha, Amaya Perera, Ayesha Fathima.Nethmi Fernando, Sanduni Rajapaksha, Amaya Perera, Ayesha Fathima.
2In qryHighICT sorted Descending, the first student is…Descending sort කළ qryHighICT හි පළමු සිසුවා…
✔ Correct!නිවැරදියි!✘ Not quite.වැරදියි. Correct answerනිවැරදි පිළිතුර: D
Highest first.ඉහළම පළමුව.
3Criteria for marks less than 50 is…50 ට අඩු ලකුණු සඳහා criteria…
✔ Correct!නිවැරදියි!✘ Not quite.වැරදියි. Correct answerනිවැරදි පිළිතුර: B
Less than.අඩු.
4qryFail (ICTMarks <50, Ascending) lists…qryFail (ICTMarks <50, Ascending) ලැයිස්තු කරන්නේ…
✔ Correct!නිවැරදියි!✘ Not quite.වැරදියි. Correct answerනිවැරදි පිළිතුර: C
Ascending: lowest first.Ascending: අඩුම පළමුව.
5The operator meaning ‘not equal to’ is…‘අසමාන’ අර්ථය ඇති operator එක…
✔ Correct!නිවැරදියි!✘ Not quite.වැරදියි. Correct answerනිවැරදි පිළිතුර: A
Access uses <>.Access <> භාවිත කරයි.
6Like “A*” on StudentName returns how many students?StudentName මත Like “A*” සිසුන් කීයක් දෙයිද?
✔ Correct!නිවැරදියි!✘ Not quite.වැරදියි. Correct answerනිවැරදි පිළිතුර: B
Amaya Perera, Arun Kumar, Ashen Jayasinghe, Ayesha FathimaAmaya Perera, Arun Kumar, Ashen Jayasinghe, Ayesha Fathima
7In Like, the wildcard for any number of characters is…Like හි ඕනෑම අක්ෂර ගණනකට wildcard එක…
✔ Correct!නිවැරදියි!✘ Not quite.වැරදියි. Correct answerනිවැරදි පිළිතුර: C
Star.තරුව.
8Price Between 600 And 1000 – is a book of Rs. 600 included?Price Between 600 And 1000 – රු. 600 පොතක් ඇතුළත්ද?
✔ Correct!නිවැරදියි!✘ Not quite.වැරදියි. Correct answerනිවැරදි පිළිතුර: D
Amba Yaluwo Rs. 600 is in the result.Amba Yaluwo රු. 600 ප්රතිඵලයේ ඇත.
9ClassID “10B” AND ICTMarks >70 gives…ClassID “10B” AND ICTMarks >70 දෙන්නේ…
✔ Correct!නිවැරදියි!✘ Not quite.වැරදියි. Correct answerනිවැරදි පිළිතුර: A
Tharindu has 39.Tharindu ට 39.
10To combine conditions with AND in Query Design, type them…Query Design හි AND සමඟ කොන්දේසි ඒකාබද්ධ කිරීමට type කරන්නේ…
✔ Correct!නිවැරදියි!✘ Not quite.වැරදියි. Correct answerනිවැරදි පිළිතුර: A
Same row.එකම පේළිය.
11ClassID “10C” OR Prefect = Yes returns how many students?ClassID “10C” OR Prefect = Yes සිසුන් කීයක් දෙයිද?
✔ Correct!නිවැරදියි!✘ Not quite.වැරදියි. Correct answerනිවැරදි පිළිතුර: C
Amaya Perera, Ashen Jayasinghe, Dilini Wickramasinghe, Malith Herath, Nethmi FernandoAmaya Perera, Ashen Jayasinghe, Dilini Wickramasinghe, Malith Herath, Nethmi Fernando
12Sorting names Z → A is…නම් Z → A sort කිරීම…
✔ Correct!නිවැරදියි!✘ Not quite.වැරදියි. Correct answerනිවැරදි පිළිතුර: C
Descending.Descending.
13To use a field for criteria but hide it from the result, you…Field එකක් criteria සඳහා භාවිත කර ප්රතිඵලයෙන් සැඟවීමට…
✔ Correct!නිවැරදියි!✘ Not quite.වැරදියි. Correct answerනිවැරදි පිළිතුර: B
Show box.Show box.
14Returned = No on tblBorrow lists how many loans?tblBorrow මත Returned = No ණය කීයක් ලැයිස්තු කරයිද?
✔ Correct!නිවැරදියි!✘ Not quite.වැරදියි. Correct answerනිවැරදි පිළිතුර: D
Not yet returned.තවම ආපසු නොදුන්.
15(SQL extra) In SELECT … FROM tblStudent WHERE ICTMarks >= 75 ORDER BY ICTMarks DESC, the criteria part is…(SQL අමතර) SELECT … FROM tblStudent WHERE ICTMarks >= 75 ORDER BY ICTMarks DESC හි criteria කොටස…
✔ Correct!නිවැරදියි!✘ Not quite.වැරදියි. Correct answerනිවැරදි පිළිතුර: B
WHERE.WHERE.
MCQ answer keyMCQ පිළිතුරු
- A – Nethmi Fernando, Sanduni Rajapaksha, Amaya Perera, Ayesha Fathima.Nethmi Fernando, Sanduni Rajapaksha, Amaya Perera, Ayesha Fathima.
- D – Highest first.ඉහළම පළමුව.
- B – Less than.අඩු.
- C – Ascending: lowest first.Ascending: අඩුම පළමුව.
- A – Access uses <>.Access <> භාවිත කරයි.
- B – Amaya Perera, Arun Kumar, Ashen Jayasinghe, Ayesha FathimaAmaya Perera, Arun Kumar, Ashen Jayasinghe, Ayesha Fathima
- C – Star.තරුව.
- D – Amba Yaluwo Rs. 600 is in the result.Amba Yaluwo රු. 600 ප්රතිඵලයේ ඇත.
- A – Tharindu has 39.Tharindu ට 39.
- A – Same row.එකම පේළිය.
- C – Amaya Perera, Ashen Jayasinghe, Dilini Wickramasinghe, Malith Herath, Nethmi FernandoAmaya Perera, Ashen Jayasinghe, Dilini Wickramasinghe, Malith Herath, Nethmi Fernando
- C – Descending.Descending.
- B – Show box.Show box.
- D – Not yet returned.තවම ආපසු නොදුන්.
- B – WHERE.WHERE.
Structured Questionsව්යුහගත ප්රශ්න
1Using the query grid in Figure 9.8: (i) name the table, (ii) give the criteria, (iii) state the sort order, (iv) write the result. (4 marks)රූපය 9.8 query grid භාවිතයෙන්: (i) table නම, (ii) criteria, (iii) sort පිළිවෙල, (iv) ප්රතිඵලය ලියන්න. (ලකුණු 4) (4 marksලකුණු 4)
Show model answerආදර්ශ පිළිතුර පෙන්වන්න
2Write the criteria for: (i) class 10A, (ii) names beginning with A, (iii) price from 600 to 1000, (iv) category not Novel. (4 marks)Criteria ලියන්න: (i) 10A පන්තිය, (ii) A න් ආරම්භ වන නම්, (iii) මිල 600 සිට 1000, (iv) Novel නොවන කාණ්ඩය. (ලකුණු 4) (4 marksලකුණු 4)
Show model answerආදර්ශ පිළිතුර පෙන්වන්න
3Find the 10B students with ICTMarks >70. Show how AND is entered and give the result. (3 marks)ICTMarks >70 ඇති 10B සිසුන් සොයන්න. AND ඇතුළත් කරන ආකාරය සහ ප්රතිඵලය දෙන්න. (ලකුණු 3) (3 marksලකුණු 3)
Show model answerආදර්ශ පිළිතුර පෙන්වන්න
4Explain the difference between AND and OR criteria with an example. (2 marks)උදාහරණයක් සමඟ AND සහ OR criteria අතර වෙනස පැහැදිලි කරන්න. (ලකුණු 2) (2 marksලකුණු 2)
Show model answerආදර්ශ පිළිතුර පෙන්වන්න
5List the students with ICTMarks <50 sorted Ascending, and suggest one use of this query for the teacher. (2 marks)ICTMarks <50 ඇති සිසුන් Ascending ලෙස ලැයිස්තු කර, ගුරුවරයාට මෙම query එකේ එක් භාවිතයක් යෝජනා කරන්න. (ලකුණු 2) (2 marksලකුණු 2)
Show model answerආදර්ශ පිළිතුර පෙන්වන්න
🎮 Game🎮 ක්රීඩා
Summary & Downloadsසාරාංශය සහ බාගත කිරීම්
Key pointsප්රධාන කරුණු
- A query selects fields and records; Run (!) shows the result.Query fields සහ records තෝරයි; Run (!) ප්රතිඵලය පෙන්වයි.
- Grid rows: Field, Table, Sort, Show, Criteria, or.Grid පේළි: Field, Table, Sort, Show, Criteria, or.
- Operators: = > < >= <= <>.Operators: = > < >= <= <>.
- Text in quotes "10A"; dates in #…#.පෙළ උද්ධෘතවල "10A"; දින #…# අතර.
- Like "A*": * any characters, ? one.Like "A*": * ඕනෑම අක්ෂර, ? එකක්.
- Between 600 And 1000 includes both ends.Between 600 And 1000 අන්ත දෙකම ඇතුළත්.
- AND same row (fewer); OR different rows (more).AND එකම පේළිය (අඩු); OR වෙනස් පේළි (වැඩි).
- Sort Ascending/Descending; SQL SELECT is behind it (extra).Ascending/Descending sort; පිටුපස SQL SELECT (අමතර).
