Worked Examples · Example 15
Q.Using the Student table, write SQL queries to
(i) display the names of all students whose Marks are between 70 and 85, and
(ii) display the names of all students whose Name begins with the letter 'A'.
ChseodishaTextbookSubjectiveImportance★★★★★est
100% · 15/15 Questions
You're viewing a preview — the full solution, concept, methods & PYQ mapping are locked.
Start your 14-day free trial to unlock the full solution →Both queries use SELECT ... WHERE, each with a different operator.
(i) A range of values — BETWEEN: the BETWEEN operator tests whether a value lies within a range, with both ends included. For marks from 70 to 85:
SELECT Name FROM Student
WHERE Marks BETWEEN 70 AND 85;
This is the same as writing WHERE Marks >= 70 AND Marks <= 85, but shorter and clearer.
(ii) A text pattern — LIKE: the LIKE operator matches text against a pattern using wildcards. The wildcard % stands for any number of characters (including none). To find names beginning with the letter A:
SELECT Name FROM Student
WHERE Name LIKE 'A%';
``` …
Unlock everything free for 14 days
- Full step-by-step solutions
- Concept-first explanations
- Methods, shortcuts & mistakes
- PYQ mapping + timed mock tests
Full access for 14 days. No credit card required.