SQL Questions:
Problem: 1
Consider the following tables product and client. Further answer the questions given below.
TABLE:PRODUCT
P_ID |
PRODUCTNAME |
MANUFACTURER |
PRICE |
TP01 |
TALCOM POWDER |
LAK |
40 |
FW05 |
FACE WASH |
ABC |
45 |
BS01 |
BATH SOAP |
ABC |
55 |
SH06 |
SHAMPOO |
XYZ |
120 |
FW12 |
FACE WASH |
XYZ |
95 |
TABLE:CLIENT
C_ID |
CLIENTNAME |
City |
P_ID |
01 |
COSMETIC SHOP |
Delhi |
FW05 |
06 |
TOTAL HEALTH |
Mumbai |
BS01 |
12 |
LIVE LIFE |
Delhi |
SH06 |
15 |
PRETTY WOMAN |
Delhi |
FW12 |
16 |
DREAMS |
Banglore |
TP01 |
Queries
Q.1.
To display the details of those clients whose city is “delhi”
Ans:
Select * from client where city=’Delhi’;
Q.2
To display the details of products whose price is in the range of 50 to 100
Ans:
Select * from product where price between 50 and 100;
select * from product where price>=50 and price<=100;
Q.3
TO DISPLAY THE client name ,city from table client and productname and price from the table product with their corresponding matching p_id
Ans:
Select clientname, city, productname, price from client, product where client.p_id=product.p_id;
Q.4
To increase the price of the product by 10
Ans:
Update product set price=price+10;
Q.5.
Select distinct city from client;
Ans:
Delhi
Mumbai
Banglore
Problem:2
Consider the following tables CONSIGNOR and CONSIGNEE. Further answer the questions given below.
TABLE:CONSIGNOR
CNORID |
CNORNAME |
CNORADDRESS |
CITY |
ND01 |
R SINGHAL |
24; ABC ENCLAVE |
NEW DELHI |
ND02 |
AMIT KUMAR |
123; PALM AVENUE |
NEW DELHI |
MU15 |
R KOHLI |
5/A; SOUTH STREET |
MUMBAI |
MU50 |
S KAUR |
27-K; WESTEND |
MUMBAI |
TABLE:CONSIGNEE
CNEEID |
CNORID |
CNEENAME |
CNEEADDRESS |
CNEECITY |
MU05 |
ND01 |
RAHUL KISHORE |
5; PARK AVENUE |
MUMBAI |
ND08 |
ND02 |
P DHINGRA |
16/J; MOORE ENCLAVE |
NEW DELHI |
KO19 |
MU15 |
A P ROY |
2A; CENTRAL AVENUE |
KOLKATA |
MU32 |
ND02 |
S MITTAL |
P 245; AB COLONY |
MUMBAI |
ND48 |
MU50 |
B P JAIN |
13; BLOCK D; A VIHAR |
NEW DELHI |
Queries
Q1.
To display the names of all the consignors from Mumbai
Ans
Select cnorname From consignor Where city=’mumbai’;
Q2.
To display the cneeid,cnorname,cnoradress,cneenmae,cneeaddress for every consignee
Ans
Select cneeid,cnoraddress,cneename,cneeaddess From consignor, consignee
Where consignor.cnorid=consignee.cnorid;
Q3.
To display consignee details in ascending order of cneename.
Ans
Select * From consignee Order by cneename;
Q4.
To display number of consignee from each city.
Ans
Select cneecity,count(cneecity) From consignee Group by cneecity;
Q5.
Select distinct cneecity from consignee;
Ans
Mumbai
CBSE Class 12 @ Python
Tutorials | Technical Questions | Interview Questions |
---|---|---|
C Programming C++ Programming Class 11 (Python) Class 12 (Python) |
C Language C++ Programming Python |
C Interview Questions C++ Interview Questions C Programs C++ Programs |