0% found this document useful (0 votes)
51 views

SQL XII Practice Sheet 1

Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
51 views

SQL XII Practice Sheet 1

Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Question 1:

Write queries for (i) to (iv) and find ouputs for SQL queries (v) to (viii), which are based on the
tables.

Table :
VEHICLE

1. To display CNO, CNAME, TRAVELDATE from the table TRAVEL in descending order of
CNO.
2. To display the CNAME of all customers from the table TRAVEL who are travelling by vehicle
with code Vo1 or Vo2
3. To display the CNO and CNAME of those customers from the table TRAVEL who travelled
between ‘2015-1231’ and ‘2015-05-01’.
4. To display all the details from table TRAVEL for the customers, who have travel distance
more than 120 KM in ascending order of NOE
5. SELECT COUNT (*), VCODE FROM TRAVEL GROUP BY VCODE HAVING COUNT (*) > 1;
6. SELECT DISTINCT VCODE FROM TRAVEL :
7. SELECT A.VCODE, CNAME, VEHICLETYPE FROM TRAVEL A, VEHICLE B WHERE A.
VCODE = B. VCODE and KM < 90;
8. SELECT CNAME, KM*PERKM FROM TRAVEL A, VEHICLE B WHERE A.VCODE =
B.VCODE AND A. VCODE ‘V05’;
Question 2:
Consider the following tables SCHOOL and ADMIN and answer this question :
Give the output the following SQL queries :

1. Select Designation Count (*) From Admin Group By Designation Having Count (*) <2;
2. SELECT max (EXPERIENCE) FROM SCHOOL;
3. SELECT TEACHER FROM SCHOOL WHERE EXPERIENCE >12 ORDER BY TEACHER;
4. SELECT COUNT (*), GENDER FROM ADMIN GROUP BY GENDER;
Question 3:
Write SQL qureries for (i) to (iv) and find outputs for SQL queries (v) to (viii), which are based on the
tables TRANSPORT and TRIE

Note:

 PERKS is Freight Charages per kilometer


 TTYPE is Transport Vehicle Type

Note:

 NO is Driver Number
 KM is Kilometer travelled
 NOP is number of travellers travelled in vehicle
 TDATE is Trip Date

1. To display NO, NAME, TDATE from the table TRIP in descending order of NO.
2. To display the NAME of the drivers from the table TRIP who are traveling by transport vehicle
with code 101 or 103.
3. To display the NO and NAME of those drivers from the table TRIP who travelled between
‘2015-02-10’ and ‘2015-04-01’.
4. To display all the details from table TRIP in which the distance travelled is more than 100 KM
in ascending order of NOP
5. SELECT COUNT (*), TCODE From TRIP
GROUP BY TCODE HAVNING COUNT (*) > 1;
6. SELECT DISTINCT TCODE from TRIP;
7. SELECT A.TCODE, NAME, TTYPE
FROM TRIP A, TRANSPORT B
WHERE A. TCODE = B. TCODE AND KM < 90;
8. SELECT NAME, KM *PERKM
FROM TRIP A, TRANSPORT B
WHERE A. TCODE = B. TCODE AND A. TCODE = 105′;

Question4:

Write SQL query to add a column total price with datatype numeric and size 10, 2 in a table product.

Question5:
Sonal needs to display name of teachers, who have “0” as the third character in their name. She wrote the
following query.
SELECT NAME FROM TEACHER WHERE NAME = “$$0?”;
But the query is’nt producing the result. Identify the problem

Question 6:

Deepika wants to remove all rows from the table BANK. But he needs to maintain the structure of the table.

Which command is used to implement the same?

Question 7:
While creating table ‘customer’, Rahul forgot to add column ‘price’. Which command is used to add
new column in the table. Write the command to implement the same.

Question 8:
What is the use of wildcard

Question 9:
Differentiate between DELETE and DROP table commands ?
Question 10:
Write SQL commands for the queries (i) to (iv) and output for (v) & (viii) based on a table
COMPANY and CUSTOMER.

1. To display those company name which are having prize less than 30000.
2. To display the name of the companies in reverse alphabetical order.
3. To increase the prize by 1000 for those customer whose name starts with „S?
4. To add one more column totalprice with decimal] 10,2) to the table customer
5. SELECT COUNT(*) , CITY FROM COMPANY GROUP BY CITY;
6. SELECT MIN(PRICE), MAX(PRICE) FROM CUSTOMER WHERE QTY>10;
7. SELECT AVG(QTY) FROM CUSTOMER WHERE NAME LIKE “%r%;
8. SELECT PRODUCTNAME,CITY, PRICE
FROM COMPANY, CUSTOMER WHERE
COMPANY. CID=CUSTOMER.CID AND
PRODUCTNAME=”MOBILE”;

You might also like