RG's E-Learning Centre · Book a free demo class · WhatsApp +91-9379416374

SQL SELECT with WHERE: Class 12 practice

WHERE keeps only the rows whose condition is true. Read the method, follow the three worked examples, then try the six questions.

What you should know first

  • Tables, rows and columns

The idea behind sql select with where

WHERE keeps only the rows whose condition is true. Combine conditions with AND (both true) and OR (at least one true); BETWEEN a AND b includes both ends.

Step-by-step method

  1. Read the condition carefully.
  2. Test it row by row.
  3. Count or list the rows that pass.

Worked example 1 (Basic)

Table student(name, marks, class): (Asha, 85, 11), (Ravi, 96, 9), (Meera, 93, 11), (Kabir, 67, 11), (Isha, 54, 11), (Arjun, 53, 10). Which names does SELECT name FROM student WHERE marks > 70; return?

  1. Test each row against: marks > 70
  2. Rows kept: 3
  3. Answer: Asha, Ravi, Meera

Worked example 2 (Standard)

Table student(name, marks, class): (Asha, 69, 9), (Ravi, 38, 10), (Meera, 44, 11), (Kabir, 64, 11), (Isha, 91, 10), (Arjun, 89, 11), (Zoya, 92, 11), (Dev, 57, 10). Which names does SELECT name FROM student WHERE marks >= 69 AND class = 10; return?

  1. Test each row against: marks >= 69 AND class = 10
  2. Rows kept: 1
  3. Answer: Isha

Worked example 3 (Challenge)

Table student(name, marks, class): (Asha, 94, 11), (Ravi, 92, 9), (Meera, 99, 10), (Kabir, 93, 9), (Isha, 63, 10), (Arjun, 47, 10), (Zoya, 63, 10), (Dev, 85, 9). Which names does SELECT name FROM student WHERE marks BETWEEN 64 AND 84 OR class = 10; return?

  1. Test each row against: marks BETWEEN 64 AND 84 OR class = 10
  2. Rows kept: 4
  3. Answer: Meera, Isha, Arjun, Zoya

Common mistakes and misconceptions

  • Treating BETWEEN as exclusive
  • Mixing AND with OR

Practice questions

  1. (Basic) Table student(name, marks, class): (Asha, 56, 10), (Ravi, 83, 10), (Meera, 58, 10), (Kabir, 61, 9), (Isha, 64, 11), (Arjun, 75, 11). Which names does SELECT name FROM student WHERE marks > 69; return?
  2. (Basic) Table student(name, marks, class): (Asha, 68, 10), (Ravi, 37, 11), (Meera, 42, 11), (Kabir, 45, 9), (Isha, 67, 10), (Arjun, 35, 11). Which names does SELECT name FROM student WHERE marks > 66; return?
  3. (Standard) Table student(name, marks, class): (Asha, 90, 10), (Ravi, 100, 10), (Meera, 39, 11), (Kabir, 51, 10), (Isha, 94, 9), (Arjun, 78, 9), (Zoya, 62, 9), (Dev, 37, 9). Which names does SELECT name FROM student WHERE marks >= 54 AND class = 9; return?
  4. (Standard) Table student(name, marks, class): (Asha, 44, 11), (Ravi, 77, 10), (Meera, 39, 10), (Kabir, 74, 11), (Isha, 75, 11), (Arjun, 86, 10), (Zoya, 96, 9), (Dev, 59, 9). Which names does SELECT name FROM student WHERE marks >= 67 AND class = 10; return?
  5. (Challenge) Table student(name, marks, class): (Asha, 43, 11), (Ravi, 87, 9), (Meera, 55, 9), (Kabir, 37, 10), (Isha, 40, 9), (Arjun, 95, 10), (Zoya, 38, 9), (Dev, 93, 11). Which names does SELECT name FROM student WHERE marks BETWEEN 63 AND 73 OR class = 9; return?
  6. (Challenge) Table student(name, marks, class): (Asha, 51, 10), (Ravi, 42, 9), (Meera, 68, 10), (Kabir, 84, 10), (Isha, 86, 9), (Arjun, 95, 10), (Zoya, 79, 11), (Dev, 67, 11). Which names does SELECT name FROM student WHERE marks BETWEEN 58 AND 70 OR class = 9; return?

Answer key with full working

  • Q1: Test each row against: marks > 69 → Rows kept: 2 → Answer: Ravi, Arjun
  • Q2: Test each row against: marks > 66 → Rows kept: 2 → Answer: Asha, Isha
  • Q3: Test each row against: marks >= 54 AND class = 9 → Rows kept: 3 → Answer: Isha, Arjun, Zoya
  • Q4: Test each row against: marks >= 67 AND class = 10 → Rows kept: 2 → Answer: Ravi, Arjun
  • Q5: Test each row against: marks BETWEEN 63 AND 73 OR class = 9 → Rows kept: 4 → Answer: Ravi, Meera, Isha, Zoya
  • Q6: Test each row against: marks BETWEEN 58 AND 70 OR class = 9 → Rows kept: 4 → Answer: Ravi, Meera, Isha, Dev

Syllabus note

This skill is listed under "Database Query using SQL" for Class 12 in the NCERT/CBSE books. ICSE, IGCSE, IB and state boards may teach it in a different chapter or year.

Answers on this page are generated and automatically re-checked by a second, independent calculation. They have not been reviewed by a teacher — if you spot a problem, tell us on WhatsApp.

Related practice and notes

Frequently asked questions

Which chapter is sql select with where in?

"Database Query using SQL", Class 12 Computer Science (NCERT/CBSE). Other boards may place it differently.

How were the answers checked?

Answers on this page are generated and automatically re-checked by a second, independent calculation. They have not been reviewed by a teacher — if you spot a problem, tell us on WhatsApp.

Book a free demo class