Professional Documents
Culture Documents
Page 1 of 6
13 What is difference between ON and USING join-clause?
Ans. The difference between ON and USING sub-clauses of JOIN clause of SELECT is that ON clause requires a
complete-join condition whereas USING clause requires just the name of a join-field. USING sub clause produces
natural join whereas ON clause produces equi-join.
14 A table STUDENT has 4 rows and 2 columns and another table TEACHER has 3 row and 4 columns. How many
rows and columns will be there if we obtain the Cartesian product of these two tables?
Ans. 12 rows and 6 columns
TYPE B: Short Answer Questions
1 Given the following table:
Page 2 of 6
3 Given the following table:
Give the output of following SQL commands on the basis of table Library.
(i) SELECT MIN(Price) FROM Library WHERE Price<150;
(ii) SELECT AVG(Price) FROM Library WHERE QTY<3;
(iii) SELECT COUNT(DISTINCT) FROM Library;
Ans.
4 Given the following table:
Page 3 of 6
12 List all customers (name)who have orders (use EXISTS).
Ans.
13 List the sum of the totals of orders grouped by customer and state.
Ans.
14 List the sum of the totals of orders where this sum is greater than $1000 grouped by customer (id) and state and
ordered by state.
Ans.
15 List the customers (name) and their orders’ details.
Ans.
16 List the customers (name) and the total amount of all their orders.
Ans.
Consider tables EMPL, Dept, SalaryGrade. The Empl table has already been listed in earlier chapters. Schemas of
tables SalaryGrade and Dept are being shown below:
SALARYGRADE (Lowsal, HIghsal, Grade)
Dept (Deptno, DeptName, Location)
Answer Questions 17 and 18 on basis of these tables:
17 List the department names and the number of their employees.
Ans. select dname,empno from dept,empl where empl.deptno=dept.deptno;
18 List the employee names and the name of their departments.
Ans. select ename, dname from empl, dept where empl.deptno=dept.deptno;
19 What is join? How many different types of joins can you create in MySQL.
Ans.
20 There are multiple ways to create Cartesian product of two tables in MySQL. Describe them.
Ans.
21 How is a left join different from a natural join? Give Example.
Ans.
22 How is cross join different from natural join? Give Example.
Page 4 of 6
45000 (both values inclusive).
(ii) To display ICode, Price and BName of the item which has IName as “Television”?
(iii) To increase the price of all the Items by 15%.
Ans. (i) Select Item.ICode,IName,Brand.Brand from Item,Brand where item.icode=brand.icode and Item.Price
Between 20000 AND 45000;
(ii) Select Item.ICode,Price,Brand.Brand from Item,Brand where item.icode=brand.icode and Item.Iname Like
'Television';
(iii) UPDATE ITEM SET Price=Price+(Price*15/100);
24 Given below is a Table Patient.
8
3
26 In a database there are two tables “Product” and “Client” as shown below:
Page 5 of 6
(ii) To display the ClientName, City from table Client and ProductName and Price from table Product, with
their corresponding matching P_ID. (2)
(iii) To increase the price of all the products by 20. (2)
Ans. (i) SELECT * FROM Product WHERE Price BETWEEN 40 AND 120;
(ii) SELECT Clientname, City, Productname, price, P_ID FROM Product, Client WHERE Client.P_ID =
Product.P_ID;
(iii) UPDATE Product
SET Price = Price + 20;
27 In a database School there are two tables Member and Division as show below.
Page 6 of 6