S.N.
QUESTION ANSWER
1 The purpose of WHERE clause in a SQL
statement is to:
A. Create a table
B. Filter rows based on a specific condition B.
C. Specify the columns to be displayed Filter rows based on a specific
D. Sort the result based on a column condition
2 Identify the SQL command used to delete a
relation (table) from a relational database.
A. DROP TABLE (A). DROP TABLE
B. REMOVE TABLE
C. DELETE TABLE
D. ERASE TABLE
3 State whether the following statement is True True
or False:
In SQL, the HAVING clause is used to apply filter on groups
formed by the GROUP BY clause.
4 Fill in the Blank
The COUNT(*) function provides the total number
Of________within a relation (table) in a relational database.
A. Columns (D). Rows
B. Unique values
C. Not-null values
D. Rows
5
Match the following SQL functions/clauses with
their descriptions:
(B). P-2, Q-4, R-1, S-3
A. P-2, Q-4, R-3, S-1
B. P-2, Q-4, R-1, S-3
C. P-4, Q-3, R-2, S-1
D. P-4, Q-2, R-1, S-3
6 Consider the string: "Database Management
System". Write suitable SQL queries for the I. SELECT SUBSTRING('Database
Management System', 10, 6);
following:
I. To extract and display "Manage" from the string. II. SELECT INSTR('Database Management
II. Display the position of the first occurrence of "base" in System', 'base');
the given string
7 Define the term Primary Key in a database. Explain how Primary Key : A set of attributes
it is different from a Candidate Key.
that can uniquely identify each row
in a table (relation). It must contain
unique values and cannot be null.
How it differs from Candidate Key
There can be multiple Candidate
Keys in a table (relation), but only
one of them is selected as Primary
Key.
8 I. Write an SQL statement to create a
table named STUDENTS, with the CREATE TABLE STUDENTS ( StudentID NUMERIC
PRIMARY KEY,
following specifications:
FirstName VARCHAR(20),
LastName VARCHAR(10), DateOfBirth DATE,
Percentage FLOAT(10,2)
);
(ii) INSERT INTO STUDENTS
(StudentID, FirstName, LastName,
Write SQL Query to insert the following data in the Students DateOfBirth, Percentage) VALUES (1,
Supriya, Singh, 2010-08-18, 75.5
'Supriya', 'Singh', '2010-08-18', 75.5);
9. Consider the following tables:
Table 1:
EMPLOYEE which stores Employee ID (EMP_ID),
Employee Name (EMP_NAME), Employee City
(EMP_CITY) I. SELECT DEPARTMENT, AVG(SALARY)
Table 2: FROM PAYROLL GROUP BY
DEPARTMENT;
PAYROLL which stores Employee ID (EMP_ID),
Department (DEPARTMENT), Designation II. SELECT DESIGNATION FROM PAYROLL
ORDER BY SALARY DESC;
(DESIGNATION), and Salary (SALARY) for
III. SELECT EMP_NAME, DEPARTMENT FROM
various employees.
EMPLOYEE E, PAYROLL P WHERE
Note: Attribute names are written within E.EMP_ID=P.EMP_ID;
brackets.
Emp_id Emp_name Emp_city
Table: EMPLOYEE
TABLE: PAYROL
Write appropriate SQL queries for the following:
I. Display department-wise average
Salary.
II. List all designations in the decreasing
order of Salary.
III. Display employee name along with
their corresponding
departments.
Table 1:
ATHLETE, which stores AthleteID, Name,
Country. The table displays basic information
of the athletes
Table 2: I. SELECT SPORT,SUM(Medals) FROM MEDALS
MEDALS, which stores AthleteID, Sport, and GROUP BY SPORT;
Medals. The table displays the number of
II. SELECT UPPER(Name) FROM ATHLETE
medals won by each athlete in their respective
WHERE COUNTRY= 'INDIA';
sports.
III. SELECT NAME, SPORT FROM ATHLETE A,
MEDALS M WHERE A.AthleteID= .AthleteID;
I. Display the sports-wise total number of medals won.
II. Display the names of all the Indian athletes in uppercase.
III. Display the athlete name along with their corresponding
sports