Worksheets › Class 12 › Querying and SQL Functions
Class 12 · Informatics Practices worksheetQuerying and SQL Functions
CBSE Informatics Practices. Math, text and date functions, aggregate functions, GROUP BY and HAVING, ORDER BY, Cartesian product and equi-joins of two tables. Every sheet has 20 questions in three sections and an answer key, and the questions change every time.
Sample questions
Real questions from this chapter, as the app sets them. Tap Answer to see the answer and working.
Section A · multiple choice
- 1.
A single row function in SQL:
- works only on numbers
- can be used only after GROUP BY
- gives one result for the whole table
- gives one result for each row it is applied to
Answer
(d) gives one result for each row it is applied to
- 2.
What does this query return? SELECT ROUND(926.716, 2);
- 926.73
- 927
- 926.72
- 926.716
Answer
(c) 926.72
ROUND keeps 2 decimal places, rounding a 5 or more up
- 3.
What does this query return? SELECT MID('Spreadsheet', 2, 3);
- pre
- rea
- Spr
- pr
Answer
(a) pre
3 letters from position 2: pre
Section B · short answer
- 4.
Name the three categories of single row functions in MySQL and give one example of each.
Answer
Math (numeric) functions, e.g. ROUND(); text (string) functions, e.g. LENGTH(); date functions, e.g. MONTH().
- 5.
Write the output of: SELECT ROUND(861.398, 1);
Answer
861.4
round 861.398 to 1 decimal place
Section C · long answer
- 6.
Explain GROUP BY and HAVING with a suitable example query.
Answer
GROUP BY collects rows with the same value of a column into groups; an aggregate function then gives one value per group. HAVING keeps only the groups that satisfy a condition. Example: SELECT City, COUNT(*) FROM STUDENT GROUP BY City HAVING COUNT(*) > 2; lists each city with more than two students and the number of students.
definition of each (2); a correct query (2)
Fresh sheets for your child
In the app, every Querying and SQL Functions sheet is new: the app remembers the questions your child has already had and leaves them out. Print the sheet as a PDF, or use notebook mode and write the answers in a notebook.
Coming soon for Android and iPhone.