SQL Queries
SQL Queries
SQL Queries
Table: ISSUED
BID QTY ISSUED
HIST66 10
COMPI1
LITR88 15
() Write command to add primary key and foreign key in tables using alter.
(üi) Increase the price of all computer books by 70.
(iii) Display the book id, book name and quantity issued for all books which have been issued.
(iv) Display the book id, book name, author name, quantity issued for all books which price are
200 to 400.
1(b) Consider the tables
Write SQL queries for (i) to (iv), which are based on the tables :CUSTOMERS and
PURCHASES given in the question
(i) To display details of all CUSTOMERS whose CITIES are neither Delhi nor Mumbai.
(ü) To display the CNAME and CITIES of all CUSTOMERS in ascending order of their CNAME.
(ii) To display the number of CUSTOMERS along with their respective CITIES in each of the
CITIES.
(iv) To display details of all PURCHASES whose Quantity is more than 15.
1(b) Consider the tables PRODUCT and BRAND given below:
Table: PRODUCT
PCode PName UPrice Rating BID
Table: BRAND
BID BNamne
MO2 Dant Kanti
MO3 Medimnix
MO4 Pepsodent
MOS Dove
Table: EMPLOYEE
EMPID NAME DOB DEPTID DESIG SALARY
120 Alisha 23 DO01 Manager 750O0
Jan
1978
123 Nitin 10 DO02 AO 5900o
Oct
1977
129 Navjot 12 DO03 Supervisor 400oo
Jul
1971
130 Jimmy 30 DO0 4 Sales Rep
Dec
1980
131 Faiz O6 DO01 Dep 65000
Apr Manager
1984
Table: DEPARTMENT
Table: ACCESSORIES
No Name Price Id
A01 Mother Board 12000 S01
A02 Hard Disk S000 SO1
A03 Keyboard 500 S02
A04 Mouse 300 S01
A05 Mother Board 13000 S02
A06 Keyboard 400 S03
A07 LCD 6000 S04
TO8 LCD 5500 SOs
TO9 Mouse 350 SO5
T10 Hard Disk 4500 S03
Table: DEPARTMENT