WorksheetsSQL functions
Total questions: 10
Worksheet time: 5mins
The SQL statement to count distinct rows from a column is,
select COUNT DISTINCT columnname AS total_rows from tablename;
select (COUNT DISTINCT columnname) AS total_rows from tablename;
select DISTINCT columnname AS total_rows from tablename;
select COUNT (DISTINCT) AS total_rows from tablename;
The COUNT() function also counts the NULL values.
True
False
The SUM() function returns - - -
some random values from the given column
the total number of columns in the database
the total number of tables in the given databases
the total sum of a given numeric column
In a column named "age", containing values 4, 5, 0, NULL, 6 the SQL statement "SELECT SUM(age) FROM students;" will return,
3
15
0
1
The average value of the given numeric column is calculated by using - - - function.
GETAVG()
FINDAVG()
AVG()
AVGVALUE()
Which one of the following is an Multiple row Functions?
COUNT()
LEN()
AVERAGE()
NOW()
A table T_COUNT has 12 number values as 1, 2, 3, 32, 1, 1, null, 24, 12, null, 32, null. Predict the output of the below query.
SELECT COUNT (*) FROM t_count;
12
6
9
Throws exception because COUNT function doesn't works with NULL values
A table stud has a column age with 7 records as 10, 12, 13, 32, null, 24, null. Predict the output of the below query.
SELECT COUNT (age) FROM stud;
5
6
Error
7
A table Books has a column DateOfPurchase with 4 records as NULL, 22-1-2008, 18-3-2008, 24-1-2011. Predict the output of the below query.
SELECT MAX (dateofPurchase) FROM Books;
24-1-2011
22-1-2008
NULL
18-3-2008
A table Books has a column DateOfPurchase with 4 records as NULL, 22-1-2008, 18-3-2008, 24-1-2011. Predict the output of the below query.
SELECT MIN (dateofPurchase) FROM Books;
24-1-2011
22-1-2008
NULL
18-3-2008
