CS Practicals With Answer-D508b01c-3967

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 9

1.

To display the details of those Clients whose city is Delhi

Select * from CLIENT where City = Delhi;


2.To display the details of Products whose Price is in the range of 50 to 100.

Select * from PRODUCT where Price BETWEEN 10 AND 20;


3.To increase the Price of all Products by 10.

Update PRODUCT
SET Price= Price+10;
4.SELECT DISTINCT City FROM Client;

City
Delhi
Mumbai
Bangalore
5. SELECT Manufacturer, MAX(Price), Min(Price), Count (*) FROM Product GROUP BY Manufacturer;

Manufacturer MAX(Price) Min(Price) Count(*)


LAK 40 40 1
ABC 55 45 2
XYZ 120 95 2

1.To display the details of those Customers whose city is Delhi.

Select * from CUSTOMER where City = Delhi;


2.To display the details of Item whose Price is in the range of 35000 to 55000 (Both values included).

Select * from PRODUCT where Price BETWEEN 35000 AND


55000;
3.To display the CustomerName, City from table Customer, and ItemName and Price from table Item, with their
corresponding matching P_ID.

Select CustomerName, City, ItemName, Price from


ITEM,CUSTOMER where ITEM.P_ID=CUSTOMER.P_ID;
4.SELECT DISTINCT City FROM Customer;

City
Delhi
Mumbai
Bangalore
5.SELECT ItemName, MAX(Price), Count(*) FROM Item GROUP BY ItemName;

ItemName MAX(Price) Count(*)


Personal Computer 37000 3
Laptop 57000 2

1.To display the names of all consignors from Mumbai.

Select CnorName from CONSIGNOR where City=Mumbai;


2.To display the consignee details in ascending order of CneeName.

Select * from CONSIGNEE


ORDER BY CneeName;
3.To delete the CneeName details RahulKishre from the table consignee.

DELETE FROM CONSIGNEE


Where CneeName=”RabulKishore”;
4.SELECT DISTINCT City FROM CONSIGNEE;

City
Mumbai
New Delhi
Kolkata

5.SELECT CneeID, CneeName FROM Consignee WHERE CnorID = ‘MU15’ OR CnorID = ‘ND01’;

CneeID CneeName
MU05 ND01
KO19 MU15
1.Display FL_NO and NO_FLIGHTS from “KANPUR” TO “BANGALORE” from the table FLIGHTS

Select FL_NO,NO_FLIGHTS from FLIGHTS


Where STARTING=”KANPUR” AND ENDING=”BANGALORE”;
2.Arrange the contents of the table FLIGHTS in the ascending order of FL_NO

Select * from FLIGHTS


ORDDER BY FL_NO;
3.Display the minimum fare “Indian Airlines” is offering from the tables FARES

Select min(fare) from FARES


WHERE AIRLINES= “INDIAN AIRLINES”;
4.Select FL_NO,NO_FLIGHTS,AIRLINES from FLIGHTS, FARES Where STARTING = “DELHI” AND FLIGHTS.FL_NO =
FARES.FL_NO;

FL_NO NO_FLIGHTS AIRLINES


IC302 8 INDIAN AIRLINES
AM501 1 JET AIRWAYS
IC701 4 INDIAN AIRLINES

5.SELECT count (distinct ENDING) from FLIGHTS;

count (distinct ENDING)

(vi) Display NAME of all doctors who are in “MEDICINE” having more than 10 years experience from the Table
DOCTOR.

Select NAME FROM DOCTOR


WHERE DEPT=”MEDICINE” AND EXPERIENCE> 10;
(vii) Display the minimum ALLOWANCE of female doctors.

Select MIN(ALLOWANCE) from DOCTOR,SALARY


WHERE DOCTOE.ID=SALARY.ID AND SEX=F;

(viii) Display the highest consultation fee among all male doctors

Select MIN(CONSULTAION) from DOCTOR,SALARY


WHERE DOCTOR.ID=SALARY.ID AND SEX=M;
(ix) SELECT count (*) from DOCTOR where SEX = “F”;

count (*)

4
(x) SELECT NAME, DEPT, BASIC from DOCTOR, SALRY Where DEPT = “ENT” AND DOCTOR.ID = SALARY.ID;

NAME DEPT BASIC


Johan ENT 12000
Lucy ENT NULL
A) To show details of all PC with stock more than 110.

Select * from PRODUCT


WHERE STOCK>110;
B) To show number of products from each company.

Select count(PNAME) from PRODUCT


GROUP BY COMPANY;
C) To Count the number of products whose price is greater than 15000.

Select count() from PRODUCTS


WHERE PRICE> 15000;
D) Alter the table to add new column as discount in float;

ALTER TABLE PRODUCT


ADD(discount number(4,2));
E) Update the column with 10 % discount on Price

UPDATE PRODUCT
SET PRICE=PRICE+PRICE*0.1;
(i) Select COUNT (distinct company) from PRODUCT;

count (distinct company)

(ii) Select MAX (price) from PRODUCT where WARRANTY <=3

MAX(PRICE)
39000

You might also like