0% found this document useful (0 votes)
49 views19 pages

SQL DB

The document contains a series of SQL questions covering various topics such as DDL and DML commands, data types, aggregate functions, and constraints. It includes multiple-choice questions, assertions with reasoning, and fill-in-the-blank queries related to SQL syntax and functionality. Additionally, there are practical tasks requiring SQL commands for modifying tables and constraints.

Uploaded by

ckamali5311
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)
49 views19 pages

SQL DB

The document contains a series of SQL questions covering various topics such as DDL and DML commands, data types, aggregate functions, and constraints. It includes multiple-choice questions, assertions with reasoning, and fill-in-the-blank queries related to SQL syntax and functionality. Additionally, there are practical tasks requiring SQL commands for modifying tables and constraints.

Uploaded by

ckamali5311
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

SQL QUESTIONS

1.Which of the following commands is not a DDL command?


(a) DROP (b) DELETE (c) CREATE (d) ALTER
2.Which of the following keywords will you use in the following query to display the unique values
of the column dept_name?
SELECT --------------------- dept_name FROM Company;
(a)All (b) key (c) Distinct (d) Name
3. What is the maximum width of numeric value in data type int of MySQL.
a. 10 digits b. 11 digits c. 9 digits d. 12 digits
4. SUM (), AVG () and COUNT () are examples of functions.
a) single row functions b) aggregate functions c) math function d) date function
5. Assertion (A): The HAVING clause in MySQL is used to filter records after the GROUP BY
operation.
RAeason (R): The WHERE clause filters records before grouping, while HAVING allows for
conditions on aggregated data.
6. Fill in the blank: _____________ command is used to add a column in a table in SQL.
7. _______Keyword is used to obtain Non-duplicated values in a SELECT query.
(a) ALL (b) DISTINCT (c) SET (d) HAVING
8.Which SQL function returns the sum of values of a column of numeric type?
(a)total( ) (b)add( ) (c) sum( ) (d) All of these
9.Assertion (A): COUNT(*) function count the number of rows in a relation.
Reasoning (R): DISTINCT ignores the duplicate values.
10. Which of the following attributes can be considered as a choice for primary key?
(a) Name (b) Street (c) Roll No (d) Subject
11.Which statement is used to modify data in a table?
(a) CHANGE (b) MODIFY (c) UPDATE (d) ALTER
12. How would you return all the rows from a table named "Item" sorted in descending order on the
column "IName"?
(a) SELECT * FROM Item SORT 'IName' DESC;
(b) SELECT * FROM Item ORDER BY IName DESC ;
(c) SELECT * FROM Item ORDER IName DESC ;
(d) SELECT * FROM Item SORT BY 'IName' DESC;
13. In a relational database table with one primary key and three unique constraints defined on different
columns (not primary), how many candidate keys can be derived from this configuration?
(A) 1 (B) 3 (C) 4 (D) 2
14.What will be the output of the query?
SELECT * FROM orders WHERE order_date LIKE '2024- 10-%';
(A) Details of all orders placed in October 2024
(B) Details of all orders placed on October 10th, 2024
(C) Details of all orders placed in the year 2024
(D) Details of all orders placed on any day in 2024
15. Which of the following statements about the CHAR and VARCHAR datatypes in SQL is false?
(A) CHAR is a fixed-length datatype, and it pads extra spaces to match the specified length.
(B) VARCHAR is a variable-length datatype and does not pad extra spaces.
(C) The maximum length of a VARCHAR column is always less than that of a CHAR column.
(D) CHAR is generally used for storing data of a known, fixed length.
16. Which of the following aggregate functions can be employed to determine the number of unique
entries in a specific column, effectively ignoring duplicates?
(A) SUM () (B) COUNT() (C) AVG() (D) COUNT(DISTINCT column_name)
17. If a table has 1 primary key and 3 candidate key, how many alternate keys will be in the table.
i) 4 ii) 3 iii)2 iv)1
18. What will be the output of the following query?
Mysql> SELECT * FROM CUSTOMER WHERE CODE LIKE ‘_A%’
A) Customer details whose code’s middle letter is A
B) Customers name whose code’s middle letter is A
C) Customers details whose code’s second letter is A
D) Customers name whose code’s second letter is A
19. Sushma created a table named Person with name as char(20) and address as varchar(40).
She inserted a record with “Adithya Varman” and address as “Vaanam Illam, Anna Nagar IV Street”.
State how much bytes would have been saved for this record.
i)(20,34) ii)(30,40) iii)(14,40) iv)(14,34)
20. ____ gives the number of values present in an attribute of a relation.
a)count(distinct col) b)sum(col) c)count(col) d)sum(distinct col)
21. Assertion (A) : DROP is a DDL command
Reason(R ) : It is used to remove all the content of a database object
22. Which function is used to display the total number of records/cardinality from table in a database?
(a) sum(*) (b) total(*) (c) count(*) (d) return(*)
23. Which of the following types of table constraints will prevent the entry of duplicate rows?
(a) Unique (b) Distinct (c) Primary Key (d) NULL
24. Assertion (A): The BETWEEN operator in SQL is used to match a within a range of values.
Reasoning (R): The BETWEEN operator can only be used with numerical values in SQL.
25. In SQL, what is the use of IS NULL operator?
26. Which of the following is not an integrity constraint?
(a) Not null (b) Composite key (c) Primary key (d) Check
27. Choose the correct command to delete an attribute A from a relation R.
a) ALTER TABLE R DELETE A (b) ALTER TABLE R DROP A
(c) ALTER TABLE DROP A FROM R (d) DELETE A FROM R
28. In the relational model, relationships among relations/table are created by using keys.
(a) composite (b) alternate (c) candidate (d) foreign
29.Which of the following aggregate functions ignore NULL values?
(a) COUNT (b) MAX (c) AVERAGE (d) All of these
30. Which of the following is a DML command?
(a) SELECT (b) ALTER (c) CREATE (d) DROP
31. Which of the following will display all the tables in a database :
a) SELECT * FROM ; b) DISPLAY TABLES; c) SHOW TABLES; d) USE TABLES;
32. _________ is the number of columns in a table and _________ is the number of rows in the table.
a) Cardinality, Degree b) Degree, Cardinality c) Domain, Range d) Attribute, Tuple
33. __________ The clause is used to display result of an SQL query in ascending or descending
order with respect to specified attribute values.
34. Which function is used to display the sum of values in a specified column?
a) COUNT(column) b) TOTAL(column) c) SUM(column) d) ADD(column)
35. Which is known as range operator in MySQL.
a) IN b) BETWEEN c) IS d) DISTINCT
36. If column “salary” of table “EMP” contains the dataset {10000, 15000, 25000, 10000,25000},
what will be the output of following SQL statement?
SELECT SUM(DISTINCT SALARY) FROM EMP;
a) 75000 b) 25000 c) 10000 d) 50000
37. Which of the following functions is used to find the largest value from the given data in MySQL?
a) MAX ( ) b) MAXIMUM ( ) c) LARGEST ( ) d) BIG ( )
38. Name the clause used in query to place the condition on groups in MySQL?
39. Assertion : Delete command is used to remove rows or records from table.
Reason : This command is used to remove records along with structure of the table from database.
40. All aggregate functions except ignore null values in their input collection.
a) Count (attribute) (b) Count (*) (c) Avg () (d) Sum ()
41. Which of the following SQL commands will change the attribute value of an existing tuple in a table?
(a) Insert (b) Update (c) alter (d) change
42. An attribute or set of attributes in a table that can become a primary key is termed as ………….
(a) Alternate key (b) Candidate key (c) Foreign key (d) Unique key.
43. The SELECT statement when combined with clause, is used for pattern matching
(a) Order by (b) Distinct (c) like (d) between
44. Identify the invalid SQL aggregate function from the following
(a) sum (b) max (c)min (d) add
45. Sonal needs to display name of teachers, who have “O” as the third character in their name.
She wrote the following query:
SELECT NAME FROM TEACHER WHERE NAME = ”**O”;
But the query isn’t producing the result. Identify the problem and write the correct query.
46. Consider the following statement:
SELECT * FROM product ORDER BY rate _______, item_name _______ ;
Which of the following option should be used do display the ‘rate’ from greater to smaller and
‘name’ in alphabetical order?
A) ASC, DESC B) DESC, ASC C) Descending, Ascending D) Ascending, Descending
47. Assertion (A): The HAVING clause is used with aggregate functions.
Reasoning (R): WHERE clause places condition on individual rows
48. In a table in MySQL database, an attribute X of datatype varchar(15) has the value ‘Computer’.
The attribute Y of datatype char(15) has the value ‘Science’. How many characters are occupied by attribute
X and attribute Y?
(a) 15, 7 (b) 8, 15 (c) 8, 7 (d) 7, 8
49. Assertion (A): A foreign key establishes a relationship between two tables.
Reason (R): A foreign key must contain unique values in the parent table.
50. In a relational database, what happens when a primary key that is referenced by a foreign key in another table is
updated?
(a) The referenced foreign key values in the other table are automatically updated to match.
(b) All related records in the referencing table are deleted.
(c) The update fails if the database enforces referential integrity.
(d) The primary key is updated but the foreign key values remain unchanged.
51. What will be the output of the given query?
SELECT * FROM employees WHERE email LIKE '%@gmail.com';
(a) Details of employees with email addresses that contain ‘@gmail.com’
(b) Details of employees with email addresses starting with ‘@gmail.com’
(c) Details of employees with email addresses that end with ‘@gmail.com’
(d) Details of employees with email addresses that contain ‘gmail’
52.What does AND operator do in SQL WHERE clause?
(a) It filters rows based on a single condition.
(b) It combines two or more conditions and returns rows where all conditions are true.
(c) It sorts the results based on multiple conditions.
(d) It combines multiple tables in the result set.
53. Assertion (A): In SQL, DELETE command removes rows from a table based on specified conditions.
Reasoning (R): DELETE command temporarily removes data from a table, which can be undone with backups.
54. Which of the following is NOT a valid SQL data type?
(a) VARCHAR (b) TEXT (c) BOOLEAN (d) STRING
55. Which of the following best describes the relationship between primary and foreign keys in a database?
(a) A primary key in one table must always correspond to a primary key in another table.
(b) A foreign key in one table references a primary key in the same table only.
(c) A foreign key in one table establishes a link to a primary key in another table to enforce referential integrity.
(d) A primary key is required to reference multiple foreign keys in different tables simultaneously.
56. Which data type would you choose to store a 10-digit phone number including the country code?
(a) CHAR(10) (b) VARCHAR(15) (c) INT(10) (d) DATE
57. Which of the following is not an aggregate function?
A) max( ) B) count( ) C) sum( ) D) upper( )
58. Assertion(A): In a relation of RDBMS, redundancy can be reduced.
Reasoning (R): This can be done with the help of join operations in between relation.
59. Which of the following statements about the CHAR and VARCHAR datatypes in SQL is false?
(A) CHAR is a fixed-length datatype, and it pads extra spaces to match the specified length.
(B) VARCHAR is a variable-length datatype and does not pad extra spaces.
(C) The maximum length of a VARCHAR column is always less than that of a CHAR column.
(D) CHAR is generally used for storing data of a known, fixed length.
60. Assertion (A): A GROUP BY clause in SQL can be used without any aggregate functions.
Reasoning (R): The GROUP BY clause is used to group rows that have the same values in specified columns
and must always be paired with aggregate functions.
61. _____ gives the number of values present in an attribute of a relation. a)count(distinct col) b)sum(col) c)count(col)
d)sum(distinct col)
62. Assertion (A) : DROP is a DDL command
Reason(R ) : It is used to remove all the content of a database object
63. LIKE clause is used for.
(a) For pattern matching
(b) For table matching
(c) For inserting similar data in a table
(d) For deleting data from a table
64. Count(*) method count
(a) NULL values only (b)Empty Values (c) ALL the values (d) None of these
65. If a table has 1 primary key and 3 candidate key, how many alternate keys will be in the table.
i) 4 ii) 3 iii)2 iv)1
66. What will be the output of the following query?
Mysql> SELECT * FROM CUSTOMER WHERE CODE LIKE ‘_A%’
A) Customer details whose code’s middle letter is A
B) Customers name whose code’s middle letter is A
C) Customers details whose code’s second letter is A
D) Customers name whose code’s second letter is A
67. Which of the following SQL commands will change the attribute value of an existing tuple in a table?
(a) Insert (b) Update (c) alter (d) change
68. An attribute or set of attributes in a table that can become a primary key is termed as ………….
(a) Alternate key (b) Candidate key (c) Foreign key (d) Unique key
69. Choose the correct option:
_________is the number of columns in a table and _____________ is the number of rows in the table.
a) Cardinality, Degree b) Degree, Cardinality c) Domain, Range d) Attribute, Tuple
70. Fill in the blank:
___________is a candidate key which is not selected as a primary key.
a. Primary Key b. Foreign Key c. Candidate Key d. Alternate Key
2marks:
1.Explain the following with help of example. 1. Primary Key 2. Candidate key
2.Ms. Rajni has just created a table named “Customer” containing columns Cname, Department and
Salary. After creating the table, she realized that she has forgotten to add a primary key column in the
table. Help her in writing an SQL command to add a primary key column Custid of integer type to the
table Customer. Thereafter, write the command to insert the following record in the table: Custid- 555
Cname- Nandini Department: Management Salary- 45600
3.Manish is working in a database named CCA, in which he has created a table named “DANCE”
containing columns danceID, Dancename, no_of_participants, and category. After creating the table, he
realized that the attribute, category has to be deleted from the table and a new attributeTypeCCA of
data type string has to be added. This attribute TypeCCA cannot be left blank. Help Manish to write
commands to complete both the tasks.
4. Differentiate between COUNT(* ) and COUNT(COLUMN_NAME) with example
5. i) What constraint should be applied on a table’s column to provide it the default value when column
does not have any value.
ii) What constraint should be applied on a table’s column so that NULL value is allowed in that
column and duplicate values are not allowed.
6. i) Write an SQL command to add one more column in previously defined table, named CELL.
Column name is CELL_ID with size 10 of integer type should be added in the table.
ii) Write an SQL command to permanently remove the table CELL from database.
7. i) What constraint should be applied to a table column to ensure that all values in that column must be
unique and not NULL?
ii).What constraint should be applied to a table column to ensure that it can have multiple NULL values
but cannot have any duplicate non-NULL values?
8. i)Write an SQL command to drop the unique constraint named unique_email from a column named
email in a table called Users.
ii) Write an SQL command to add a unique constraint to the email column of an existing table named
Users, ensuring that all email addresses are unique.
9. Identify Primary Key and Candidate Key present if any in the below table name Colleges. Justify
Cid Name Location Year Strength AffiUniv PhoneNumber
1 St. Xavier's Mumbai 1869 10000 University 022-12345678
College of Mumbai
2 Loyola College Chennai 1925 5000 University 044-87654321
of Madras
3 Hansraj College New Delhi 1948 4000 Delhi 011-23456789
University
4 Christ University Bengaluru 1969 8000 Christ 080-98765432
University
5 Lady Shri Ram New Delhi 1956 2500 Delhi 011-34567890
College University
10. (A) What constraint/s should be applied to the column in a table to make it as alternate key?
OR
(B) What constraint should be applied on a column of a table so that it becomes compulsory to insert the
value
(II) (A) Write an SQL command to assign F_id as primary key in the table named flight 2 import random
word='Inspiration' Lot=2*random.randint(2,4) for i in range(Lot,len(word),3): print(word[i],end='$')
OR (B)Write an SQL command to remove the column remarks from the table name customer.
11) An attribute A of datatype varchar(20) has the value “Amit” . The attribute B of datatype char(20)
has value ”Karanita” . How many characters are occupied in attribute A ? How many characters are
occupied in attribute B?
12) While creating a table named “Employee”, Mr. Rishi got confused as which data type he should
choose for the column “EName” out of char and varchar. Help him in choosing the right data type to
store employee name. Give valid justification for the same.
13. What do you understand by Candidate keys in a table? Give a suitable example of candidate keys
from a table containing some meaningful data.
14. Differentiate between Drop and Delete commands of MYSQL. Write its syntax
15. For a table “Company” having column cno, cname, department and salary, write the SQL statement
to display average salary of each department.
16. Differentiate between COUNT(*) and SUM( ) functions in SQL with appropriate example
17. Differentiate between equi join and cross join function in SQL with an example.
18. Observe the table CLUB given below:

(i) What is the cardinality and degree of the given table?


(ii) Which field should be made the primary key? Justify your answer.
3marks
1.

2. Mohan is a senior clerk in a MNC. He creates a table salary with a set of records to keep ready for tax
calculation. After creation of the table, he has entered data of 5 employees in the Employee table

Based on the table given above write the SQL Queries:


i) To Display the Emp_Name and Gross_salary of each employee. (Gross= basic+da+hra+nps)
(ii) To Increase the DA by 3% of respective basic salary of all employees.
(iii) To Delete the Attribute emp_desig from the table.
(iV) To display the total number of employees in Employee table.
(V) To display the employees records in descending order of basic_salary respectively.
(VI) To display the total hra of employees in Employee table
3. Difference between WHERE and HAVING.
4 marks
1. Consider the following tables and answer the questions a and b: Table: Garment

Write SQL queries for the following:


i. Display unique quantities of garments.
ii. Display sum of quantities for each CCODE whose numbers of records are more than 1.
iii. Display GNAME, CNAME, RATE whose quantity is more than 100.
iv. Display average rate of garment whose rate ranges from 1000 to 2000 (both values included)
2. Write the SQL queries (i) to (iv) based on the relations SCHOOL and ADMIN given below:

Write SQL queries for the following:


i) Display total periods subjectwise by framing groups based on subject.
ii) Display minimum experience and maximum code from relation SCHOOL.
iii)Display teachername, gender by joining both tables on the basis of code ATTRIBUTE and the
designation should be “COORDINATOR.
iv) (A) Display the total number of different subjects in school relation.
OR (B) To display the total number of Males and Females separately with gender in ADMIN table.
3. Consider the table ORDERS as given below

Note: The table contains many more records than shown here.
A) Write the following queries:
(I) To display the total Quantity for each Product, excluding Products with total Quantity less than 5.
(II) To display the ORDERS table sorted by total price in descending order.
(III) To display the distinct customer names from the ORDERS table.
(IV) To display the sum of the Price of all the orders for which the quantity is NULL.
(Or)
Write the output:
(I) SELECT C_Name, SUM(Quantity) AS Total_Quantity FROM ORDERS GROUP BY C_Name;
(II) SELECT * FROM ORDERS WHERE Product LIKE '%phone%';
(III) SELECT O_Id, C_Name, Product, Quantity, Price FROM ORDERS WHERE Price BETWEEN
1500 AND 12000;
(IV) SELECT MAX(Price) FROM ORDERS;
4. Alex has been tasked with managing the Student Database for a High School. He needs to access
some information from the STUDENTS and SUBJECTS tables for a performance evaluation. Help him
extract the following information by writing the desired SQL queries as mentioned below.
Table: STUDENTS
S_ID FName LName Enrollment_Date Marks
201 John Doe 15-09-2020 85
202 Jane Smith 10-05-2019 90
203 Alex Johnson22-11-2021 75
204 Emily Davis 30-01-2022 60
205 Michael Brown 17-08-2018 95
Table: SUBJECTS
Sub_ID S_ID SubName Credits
301 201 Mathematics 3
302 202 Science 4
303 203 History 2
304 204 Literature 3
305 205 Physics 4
306 201 ComputerScience 3
Write the following SQL queries:
(I) To display complete details (from both the tables) of those students whose marks are greater than 70.
(II) To display the details of subjects whose credits are in the range of 2 to 4 (both values included).
(III) To increase the credits of all subjects by 1 which have "Science" in their subject names.
(IV) (A) To display names (FName and LName) of students enrolled in the "Mathematics" subject.
(OR)
(B) To display the Cartesian Product of these two tables.
( I ) SELECT * FROM STUDENTS S JOIN SUBJECTS Sub ON S.S_ID = Sub.S_ID WHERE
S.Marks > 70;
(II) SELECT * FROM SUBJECTS WHERE Credits BETWEEN 2 AND 4;
(III) UPDATE SUBJECTS SET Credits = Credits + 1 WHERE SubName LIKE '%Science%';
(IV) A: SELECT FName, LName FROM STUDENTS S JOIN SUBJECTS Sub ON S.S_ID = Sub.S_ID
WHERE Sub.SubName = 'Mathematics';
OR
B: SELECT * FROM STUDENTS, SUBJECTS;
5. Consider the following table named Vehicle and state the query or state the output
Table:- Vehicle
VID LicensePlate VType Owner Cost Contact State
1 MH12AB1234 Car Raj Kumar 65 9876543210 Maharastra
2 DL3CDE5678 Truck Arjith Singh 125 8765432109 New Delhi
3 KA04FG9012 Motor cycle Prem Sharma 120 9123456789 Karnataka
4 TN07GH3456 SUV Shyad Usman 65 9987654321 Tamil Nadu
5 KA01AB1234 Car Devid jhon 65 9876543210 Karnataka
6 TN02CD5678 Truck Anjali Iyer 125 8765432109 Tamil Nadu
7 AP03EF9012 Motor cycle Priya Reddy 120 9123456789 Andhra Pradesh
(A)
(i) To display number of different vehicle type from the table vehicle
(ii) To display number of records entered vehicle type wise whose minimum cost is above 80
(iii)To set the cost as 45 for those vehicles whose cost is not mentioned
(iv)To remove all motor cycle from vehicle
OR
(B)
(i) SELECT VTYPE,AVG(COST) FROM VEHICLE GROUP BY VTYPE;
(ii) SELECT OWNER ,VTYPE,CONTACT FROM VEHICLE WHERE OWNER LIKE“P%”;
(iii)SELECT COUNT(*) FROM VEHICLE WHERE COST IS NULL;
(iv)SELECT MAX(COST) FROM VEHICLE;

6. Salman has been entrusted with the management of Airlines Database. He needs to access some
information from Airports and Flights tables for a survey. Help him extract the following information by
writing the desired SQL queries as mentioned below. Table – Airports

i) To display airport name, city, flight id, flight number corresponding flights whose departure is from
delhi
ii) Display the flight details of those flights whose arrival is BOM, MAA or CCU
iii) To delete all flights whose flight number starts with 6E.
iv) (A) To display Cartesian Product of two tables OR
(B) To display airport name, city and corresponding flight number
7. Consider the tables BOOK and MEMBER Given table:
Write SQL queries for the following:
(i) To display all details from table MEMBER in descending order of ISSUEDATE.
(ii) To display the CODE and BNAME of all Fiction Type books from the table Book.
(iii) To display each Member name and corresponding Bookname.
(iv) To display Booknames, Member name and issue date for books of type 'Fiction'.
8. Write the output of the queries (i) to (iv) based on the table, SALES given below:

i) SELECT DESIG FROM SALES WHERE NAME LIKE ‘%H’


; ii) SELECT DESIG, COUNT(*), MIN(SALES) FROM SALES GROUP BY DESIG HAVING
COUNT(DESIG)>1;
iii) SELECT NAME,SALES FROM SALES WHERE SALES BETWEEN 100000 AND 1000000;
iv) SELECT DESIG, SUM(SALES) FROM SALES GROUP BY DESIG;

9. Consider the following MOVIE table and write the SQL queries based on it.

a) Display all the information


from the Movie table.
b) List business done by the movies showing only MovieID, MovieName and Total_Earning. Total_Earning
to be calculated as the sum of ProductionCost and BusinessCost.
c) List the different categories of movies.
d) Find the net profit of each movie showing its MovieID, MovieName and NetProfit. Net Profit is to be
calculated as the difference between Business Cost and Production Cost
10. Consider the table MobileMaster
M_Id M_Company M_Name M_Price M_Mf_Date
MB001 Samsung Galaxy 13000 2014-02-12
MB002 Nokia N1100 7500 2011-04-15
MB003 Realme C35 12000 2021-11-20
MB004 Oppo SelfieEx 12500 2015-08-21
Based on the data given above answer the following questions
i) Identify the most appropriate column, which can be considered as Primarykey.
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) To display details of those mobiles whose price is greater than 8000.
iv) Increase the M_Price of all mobiles manufactured after 2015-01-01 by 500
11. Write the output for SQL queries (i) to (iv), which are based on the table: STUDENTgiven below

i) SELECT COUNT(*), City FROM STUDENT GROUP BY CITY HAVING COUNT(*)>1;


ii) SELECT MAX(DOB),MIN(DOB) FROM STUDENT;
iii) SELECT NAME,GENDER FROM STUDENT WHERE CITY=”Delhi”;
iv) SELECT DISTINCT Class FROM STUDENT;
12.

i)

Write any one point of difference between Equi join and Natural join.
ii) Find output:
(a)select *from product p, supplier s where p.supid=s.supid;
(b)select *from product natural join supplier;

(iii) Write a Query to insert House_Name=Tulip, House_Captain= Rajesh and House_Point=278 into
table House(House_Name, House_Captain, House_Points).
iv) What is the difference between degree and cardinality with respect to RDBMS. Give one example to
support your answer.
13.As part of Fit India Campaign, Suresh has started a juice shop that serveshealthy juices. As his
database administrator, answer the following questions based on the data given in the table below.
Table : HEALTHYDRINKS

i) Insert the following record into the table


DrinkCode – 107, Dname – Santara Special, Price – 25.00, Calorie – 130
ii) Increase the price of the juices by 3% whose name begins with ‘A’.
iii) Delete the record of those juices having calories more than 140.
iv) Add a column Vitamins in the table with datatype as varchar with 20 characters.x`
14. Write the output of the queries (i) to (iv) based on the table given below:

i) SELECT PARTICIPANT, POINTS FROM Activity ORDER BY POINTS DESC;


ii) SELECT HOUSE, COUNT(PARTICIPANT) FROM Activity GROUPBY HOUSE;
iii) SELECT DISTINCT POINTS FROM Activity;
iv) SELECT PID,EVENTDATE FROM Activity WHERE EVENT=”Running” OR
EVENT=”Skipping”;
15. In a Database company, there are two tables given below:

i) To display Worker id, name and department code(DCODE) with corresponding location names.
ii) To display worker name, gender and corresponding city names who has joined less than 2014- 01-01
iii) To display names and department those worker name who have letter anywhere ‘e’
iv) To change date of joining 2002-09-09 that worker no is 1005.
16. Consider the following tables EMPLOYEE and DEPARTMENT:

TABLE: EMPLOYEE
TCode TName DepCode Salary Age JoinDate
15 Sameer Sharma 123 75000 39 01-Apr-
2007
21 Ragvinder K 101 86000 29 11-Nov-
2005
3 Rama Gupta 119 52500 43 03-Mar-
2010
46 CR Menon 103 67000 38 12-Jul-
2004
77 Mohan Kumar 103 63000 55 25-Nov-
2000
81 Rajesh Kumar 19 74500 48 11-Dec-
2008
8 Sanjeev P 101 92600 54 12-Jan-
2009
93 Pragya Jain 123 32000 29 05-Aug-
2006
TABLE: DEPARTMENT
DepCode DepName DepHead
101 ACCOUNTS Rajiv Kumar
103 HR P K Singh
119 IT Yogesh Kumar
123 RESEARCH Ajay Dutta
Write SQL commands for the following statements:
i) To display all DepName along with the DepCode in descending order of DepCode.
ii) To display the average age of Employees in DepCode as 103.
iii) To display the name of DepHead of the Employee named “Sanjeev P”
iv) To display the details of all employees who has joined before 2007 from EMPLOYEE table.
v) SELECT COUNT (DISTINCT DepCode) FROM EMPLOYEE;
vi) SELECT MAX(JoinDate), MIN (JointDate) FROM EMPLOYEE;
vii) SELECT TName, DepHead FROM EMPLOYEE E, DEPARTMENT D WHERE
E.DepCode = D.DepCode;
viii) SELECT COUNT (*) FROM EMPLOYEE WHERE Salary > 60000 AND Age > 30;

17. Write the SQL command for the following on the basis of given table.

A)
i)Display the names of the students who have grade “A‟ in either Game 1 or Game 2 or both.
ii)Display the number of students having the GRADE1 as “A‟ in Game1.
iii)Display the names of students who have same game for both Game1 and Game2.
iv)Display the games taken by the students whose name starts with “A‟
B. (B) Give the output of the following sql statements as per table given above.
i) SELECT COUNT(*) FROM SPORTS.
ii) SELECT DISTINCT Class FROM SPORTS.
iii) SELECT MAX(Class) FROM STUDENT;
vi) SELECT COUNT(*) FROM SPORTS GROUP BY Game1;

You might also like