Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
7 views

4 WS GR12 2.1 MySQLPython

Uploaded by

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

4 WS GR12 2.1 MySQLPython

Uploaded by

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

CMR NATIONAL PUBLIC SCHOOL/ EKYA SCHOOLS

GRADE XII
Querying in MySQL

1. Write the sql queries for questions a to f and the output of given queries for questions g to j.

(a) To display the details of all items in ascending order of item name.
(b) To display the details of items whose prices are in the range 10000 to 22000 (inclusive).
(c) To display number of items traded by each trader.
(d) To display price, item and quantity of those items whose quantity is more than 150.
(e) To display the names of those traders, who are either from Delhi or from Mumbai.
(f) To display the names of the companies and the names of the items in descending order of company
names.
(g) To display INAME and TNAME for common TCODE in both tables.
(h) SELECT MAX(PRICE), MIN(PRICE) FROM ITEMS;
(i) SELECT PRICE * QTY AMOUNT FROM ITEMS WHERE CODE = 1004;
(j) SELECT DISTINCT TCODE FROM ITEMS;

2. Write SQL queries for (a) to (d) and outputs for (e) to (h) based on these tables:
(a) To display No, Name, Tdate from the table Travel in descending order of No.
(b) To display the NAME of all the travellers from the table TRAVEL who are travelling by vehicle with
code 101 or 102.
(c) To display the NO and NAME of those travellers from the table TRAVEL who travelled between
‘2015-12-31’ and ‘2015-04-01’.
(d) To display all the details from table TRAVEL for the travellers, who have travelled distance more
than 100 KM in ascending order of NOP.
(e) To display CODE, VTYPE and NAME for common CODE.
(f) SELECT COUNT (*), CODE FROM TRAVEL GROUP BY CODE HAVING COUNT(*)>1;
(g) SELECT DISTINCT CODE FROM TRAVEL;
(h) SELECT ANME, KM*PERKM FROM TRAVEL A, VEHICLE B WHERE A,CODE = B.CODE
AND A.CODE = ‘105’;

3. Write SQL queries for (a) to (d) and outputs for (e) to (h) based on these tables:
(a) To display Wno, Name, gender from the table WORKER in descending order of WNo.
(b) To display the names of all the female workers.
(c) To display Wno and names of those workers from the table WORKER who are born between ‘1987-
01-01’ and ‘1991-12-01’.
(d) To count and display male workers who have joined after ‘1986 -01-01’.
(e) SELECT COUNT(*), DCODE FROM WORKER GROUP BY DCODE HAVING COUNT (*) >
1;
(f) SELECT DISTINCT DEPARTMENT FROM DEPT;
(g) SELECT NAME, DEPARTMENT, CITY FROM WORKER W, DEPT D WHERE W.DCODE =
D.DCODE AND WNO < 1003;
(h) SELECT MAX(DOJ), MIN(DOJ) FROM WORKER.

4. Write SQL queries for (a) to (d) and outputs for (e) to (h) based on these tables:
(a) To display details of all transactions of Type Deposit from the table, Transact.
(b) To display the ANo and Amount of all Deposits and Withdrawals done in the month of October
2017 from the table Transact.
(c) To display the last date of transaction (DOT) from the table Transact for the Accounts having ANo
as 103.
(d) To display all ANo, AName and DOT of those persons from tables Account and Transact who have
done transactions less than or equal to 3000.
(e) SELECT ANO, ANAME FROM ACCOUNT WHERE ADDRESS NOT IN
(‘CHENNAI’,’BANGALORE’);
(f) SELECT DISTINCT ANO FROM TRANSACT;
(g) SELECT ANO, COUNT(*), MIN(AMOUNT) FROM TRANSACT GROUP BY ANO HAVING
COUNT(*) > 1;
(h) SELECT COUNT(*), SUM(AMOUNT) FROM TRANSACT WHERE DOT <= ‘2017-06-01’;

You might also like