0% found this document useful (0 votes)
115 views6 pages

2 3mark

The document contains 30 questions related to SQL concepts like aggregate functions, GROUP BY, HAVING clauses, data types, NULL values and more. Sample answers are provided that explain concepts like aggregate functions only work on numeric values, NULL is ignored by aggregates, GROUP BY groups data and HAVING applies conditions to groups. The differences between NOW() and SYSDATE() functions and between DELETE and DROP commands are outlined.

Uploaded by

Nasla Abdulsalam
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
115 views6 pages

2 3mark

The document contains 30 questions related to SQL concepts like aggregate functions, GROUP BY, HAVING clauses, data types, NULL values and more. Sample answers are provided that explain concepts like aggregate functions only work on numeric values, NULL is ignored by aggregates, GROUP BY groups data and HAVING applies conditions to groups. The differences between NOW() and SYSDATE() functions and between DELETE and DROP commands are outlined.

Uploaded by

Nasla Abdulsalam
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

Questions

1. Write the output of the following SQL queries:


(i) SELECT RIGHT („software‟, 2);
(ii) SELECT INSTR („twelve‟, lV);
(iii) SELECT DAYOFMONTH („2014-03-01‟);
(iv) SELECT (76.987,2); (All India 2014C)

2. There is a column Salary in a Table EMPLOYEE. The following two statements are
giving different outputs. What may be the possible reason?
SELECT COUNT(*) FROM EMPLOYEE;
SELECT C0UNT(Salary) FROM EMPLOYEE;

3. A table FLIGHT has 4 rows and 2 columns and another table AIRHOSTESS has rows
and 4 columns. How many rows and columns will be there if we obtain the cartesian
product of these two tables?

4. What is the purpose of GROUP BY clause in MySQL? How is it different from ORDER
BY clause?

5. Shanya Khanna is using a table EMPLOYEE. It has the following columns:


[Admno, Name, Agg, Stream [column Agg contains Aggregate marks]
She wants to display highest Agg obtained in each Stream.
She wrote the following statement:
SELECT Stream, MAX(Agg) FROM EMPLOYEE;
But she did not get the desired result. Rewrite the above query with necessary changes to
help her get the desired output.

6. State difference between date functions NOW() and SYSDATE() of MySql.

7. Why is it not allowed to give String and Date type arguments for SUM() and AVG()
functions? Can we give these type of arguments for other functions?

8. What is default, Autocommit mode in MySQL ?

9. Can where be added a savepoint in a transaction ?

10. How are NULL values treated by aggregate functions?

11. There is a column C1 in a table T1. The following two statements: SELECT COUNT(*)
FROM T1; and SELECT COUNT(C1) from T1; are giving different outputs. What may
be the possible reason?

12. What is the purpose of GROUP BY clause?


13. What is the difference between HAVING and WHERE clauses? Explain with the help of
an example.

14. What is a Foreign key? What is its importance?

15. What are constraints? Are constraints useful or are they hindrances to effective
management of databases?

16. In a database there is a table Cabinet. The data entry operator is not able to put NULL in
a column of Cabinet? What may be the possible reason(s)?

17. In a database there is a table Cabinet. The data entry operator is not able to put duplicate
values in a column of Cabinet? What may be the possible reason(s)?

18. Do Primary Key column(s) of a table accept NULL values?

19. There is a table T1 with combination of columns C1, C2, and C3 as its primary key? Is it
possible to enter:
a.NULL values in any of these columns?
b.Duplicate values in any of these columns?

20. What are the differences between DELETE and DROP commands of SQL?

21. What are Aggregate Functions ?

22. For what Data Types aggregate functions : MIN(), MAX(), and COUNT() work?

23. What is HAVING clause ?

24. What is Referential Integrity?

25. What is Union used for ?

26. What is ALTER TABLE ?

27. What is DROP TABLE ?

28. What function is used whenever a condition involves an aggregate function ?

29. What is Difference between GROUP BY‟ and Having functions ?

30. A table “transport” in database info has cardinality 8 and degree 3. What is the number of
column and row in transport relation.
Answers
1. Answer:
(i) re
(ii) 45
(iii) 01
(iv) 76.99

2. Answer:
SELECT COUNT (*)
FROM EMPLOYEE:
This statement returns the number of records in the table.

SELECT COUNT(Salary)
FROM EMPLOYEE;
This statement returns the number of values (NULL values will not be counted) of the
specified column.

3. Answer:
Total number of rows will be 12 and total number of columns will be 6.

4. Answer:
The GROUP BY clause can be used to combine all those records that have identical
value in a particular field or a group of fields. Whereas, ORDER BY clause is used to
display the records either in ascending or descending order based on a particular field.
For ascending order ASC is used and for descending order, DESC is used. The default
order is ascending order.

5. Answer:
SELECT Stream, MAX(Agg)
FROM EMPLOYEE
GROUP BY Stream;

6. Answer:
Differences between Now() and SYSDATE() of MySql are as follows:
7. Answer :
String and dates are not real numbers that we calculate so sum or avg functions are not
valid for them.

8. Answer :
By default, Autocommit mode is on in MySQL.

9. Answer :
We can add a savepoint anywhere in a transaction.

10. Answer :
None of the aggregate functions takes NULL into consideration. NULL is simply ignored
by all the aggregate functions.

11. Answer :
There may be a null value.

12. Answer :
GROUP BY clause is used in a SELECT statement in conjunction with aggregate
functions to group the result based on distinct values in a column.
13. Answer :
WHERE Vs HAVING: WHERE is used to put a condition on individual row of a table
whereas HAVING is used to put condition on individual group formed by GROUP BY
clause in a SELECT statement.

14. Answer :
Foreign Key: It is a column of a table which is the primary key of another table in the
same database. It is used to enforce referential integrity of the data.

15. Answer :
These are the rules which are applied on the columns of tables to ensure data integrity
and consistency. These play very important role for tables so are not hindrances.

16. Ansewr :
Not NULL or Primary key constraints used

17. Ansewr :
Primary key constraint used.

18. Answer :
No.

19. Answer :
No.

20. Answer :
Delete is used for row removing while drop is used for removing complete table.

21. Answer :
A multiple row function works on multiple values. These functions are called aggregate
functions or group functions.

22. Answer :
On any type of values - Numeric, Date, or String. AVG(), and SUM() work on only
Numeric values (INT and DECIMAL).

23. Answer :
HAVING clause is used in conjunction with GROUP BY clause in a SELECT statement
to put condition on groups.
24. Answer :
The property of a relational database which ensures that no entry in a foreign key column
of a table can be made unless it matches a primary key value in the corresponding column
of the related table.

25. Answer :
Union is an operation of combining the output of two SELECT statements.

26. Answer :
WHERE function is used for individual records and HAVING for groups . GROUP BY
function is used for getting results based on some groups of data while a condition on
groups is applied by HAVING clause.

27. Answer :
DROP TABLE command is used to delete tables.

28. Answer :
whenever a condition involves an aggregate function, then we use HAVING clause in
conjunction with GROUP BY clause.

29. Answer :
ALTER TABLE command can be used to Add, Remove, and Modify columns of a table.
It can also be used to Add and Remove constraints.

30. Answer:
Number of Row -8
Number of column- 3

You might also like