Q1.
Differentiate between count() and count(*) functions in SQL with
appropriate example.
OR
Categorize the following commands as DDL or DML:
INSERT, UPDATE, ALTER, DROP
Q2.
(a) Consider the following tables – Bank_Account and Branch:
What will be the output of the following statement?
(a) SELECT * FROM Bank_Account NATURAL JOIN Branch;
(b) Write the output of the queries
(i) to (iv) based on the table,
TECH_COURSE given below:
(i) SELECT DISTINCT TID FROM TECH_COURSE;
(ii) SELECT TID, COUNT(*), MIN(FEES) FROM
TECH_COURSE GROUP BY TID HAVING COUNT(TID)>1;
(iii) SELECT CNAME FROM TECH_COURSE WHERE
FEES>15000 ORDER BY CNAME;
(iv) SELECT AVG(FEES) FROM TECH_COURSE WHERE
FEES BETWEEN 15000 AND 17000;
Q3.
(a) Write the outputs of the SQL queries (i) to (iv) based on the
relations Teacher and Placement given below:
(i) SELECT Department, avg(salary) FROM Teacher
GROUP BY Department;
(ii) SELECT MAX(Date_of_Join),MIN(Date_of_Join) FROM
Teacher;
(iii) SELECT Name, Salary, T.Department, Place FROM
Teacher T, Placement P WHERE T.Department =
P.Department AND Salary>20000;
(iv) SELECT Name, Place FROM Teacher T, Placement P WHERE Gender =’F’ AND
T.Department=P.Department;
(b) Write the command to view all tables in a database.
Q4. Shreya creates a table RESULT with a set of records to maintain the marks secured by
students in Sem 1, Sem2, Sem3 and their division. After creation of the table, he has
entered data of 7 students in the table.
Based on the data given above answer the following questions:
(i) Identify the most appropriate column, which can be considered
as Primary key.
(ii) If two columns are added and 2 rows are deleted from the table
result, what will be the new degree and cardinality of the
above table?
(iii) Write the statements to:
a. Insert the following record into the table
Roll No- 112, Name- Vivek, Sem1- 464, Sem2-456, Sem3-
482, Div – I.
b. Increase the SEM2 marks of the students by 3% whose
name begins with ‘N’.
OR (Option for part iii only)
(iii) Write the statements to:
a. Delete the record of students securing IV division.
b. Add a column REMARKS in the table with datatype as
varchar with 50 characters.