0% found this document useful (0 votes)
23 views

SQL Functions QA

This document contains answers to questions about SQL database concepts like aggregate functions, scalar functions, GROUP BY, HAVING and more. Multiple choice, true/false and fill in the blank questions are answered explaining concepts like MAX, MIN, COUNT, SUM, AVG, WHERE, NOW and more.

Uploaded by

asmajavedsch
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views

SQL Functions QA

This document contains answers to questions about SQL database concepts like aggregate functions, scalar functions, GROUP BY, HAVING and more. Multiple choice, true/false and fill in the blank questions are answered explaining concepts like MAX, MIN, COUNT, SUM, AVG, WHERE, NOW and more.

Uploaded by

asmajavedsch
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

ICT : Module 3 – DATABASE Question Answers

Answers of textbook exercises


Fill in the Blanks
1. M I D ( ) is used for extracting characters from a text field.
2. We Use L C A S E to convert a text to lower case letters
3. H A V I N G filters data after applying an aggregate function.
4. R O U N D is used for limiting decimal places of a real number.
5. An aggregate function returns a single value for multiple r o w s.

State True or False


1. Aggregate function average() can be applied to number fields only.-True
2. Aggregate functions min() and max() can be applied to number fields only.-
False
3. HAVING clause can be used with any select query for filtering data.-False
4. GROUP BY can be used with aggregate functions only.-True
5. SQL function mid() can be used with number fields.-False

Match the Following


1. Having
Filtering
2. sum( )
Aggregate function
3. ucase( )
Capital letters
4. Now( )
Date and time

5. Mid( )
(column name, start, length)

On next page
Multiple choice questions
Questions 1-5 are based on the table given below.
tbl_data
ID NAME SCORE DOB
1 Joseph 90 2001-10-01
2 Tom 85 2003-09-21
3 Harry 88 2007-02-17
4 Paul 76 2005-07-14
5 George 79 2001-11-06

1. select Max (Score) from tb1_data;

1. 90
2. 85
3. 88
4. 76

2. Select sum (name) from tb1 data;

1. Error
2. 0
3. 1
4. 255

3. Select count (name) from tb1_data;

1. 4
2. 3
3. 5
4. 8

4. Select avg (Score) from tb1_data;

1. 81.9
2. 83.6
3. 86.3
4. 85

5. select Min (name) from tbl data;


1. Harry
2. PAUL
3. George
4. Joseph

Answer in one word or one sentence


1. write a query to list the year of birth of all candidates in the above table.

SELECT name,YEAR(birth_date) from candidates;

2. Write a query to update the name of “Tom” to “Johnny”.

UPDATE table_name SET = "Johnny" where name = "Tom";

3. What is the difference between WHERE clause and HAVING clause?

The HAVING clause was added to SQL because the WHERE keyword could
not be used with aggregate functions.

4. What is the use of GROUP BY clause?

GROUP BY clause in SQL allows you to take your result set,group it into
logical groups and then run aggregate queries on the groups.

5. Write the SQL query to print current date and time.

SELECT NOW();
Answer the following
1. What are functions in SQL?

 Aggregate Functions
 Scalar functions

2. What are aggregate functions?

 AVG()
 COUNT()
 FIRST()
 LAST()
 MAX()
 MIN()
 SUM()

3. What are scalar functions?


 UCASE()
 LCASE()
 MID()
 LENGTH()
 ROUND()
 NOW()
 FORMAT()

4. What are the differences between aggregate functions and scalar


functions?

SQL aggregate functions return a single value, calculated from the values in a
column.
SQL scalar functions return a single value for each value of a particular
column given as input.

You might also like