2. --------------------
biography
fiction
2 rows selected.
3)Type of Clothing selected by Nehal
select CLOTH_NAME from clothing1 where DID IN (Select DID from cust_dept1 where CID IN(Select CID
from customer1 where CNAME='Nehal'));
O/P:
CLOTH_NAME
--------------------
Formals
Traditional
Jeans
1 row selected.
4)Customers who dont stay in Mumbai and Delhi
select CNAME from customer where CADDRESS NOT IN('Mumbai','Delhi');
O/P:
3. CNAME
--------------------
Ena
Nehal
2 rows selected.
5)Customers who are interested in TV whose inches are in the range of 30
select CNAME from customer where CID IN (Select CID from cust_dept where DID IN(Select DID from
electronics where ENAME='TV' and EID IN(Select EID from TV where inches like('3%'))));
O/P:
CNAME
--------------------
Bharti
Ena
2 rows selected.
6)Mobile having bluetooth connectivity
select * from mobile where connectivity like ('B%');
4. O/P:
CONNECTIVITY EID
-------------------- ----------
Bluetooth E00001
Bluetooth E00001
2 rows selected.
7)Customers whose name end with 'na'
select CID,CNAME from customer where CNAME like ('%na');
O/P:
CID CNAME
---------- --------------------
C00002 Ena
C00004 Krina
C00005 Tina
3 rows selected.
8)Items belonging to Electronics department
5. select ENAME from electronics where Exists(Select DID from cust_dept where
electronics.DID=cust_dept.DID ) ;
O/P:
ENAME
--------------------
MOBILE
cameras
TV
3 rows selected.
9)Details of Items pressent in mobile section of Electronics department
Select * from electronics e ,mobile m where e.EID=m.EID;
O/P:
EID ENAME ECOST DID CONNECTIVITY EID
---------- -------------------- ---------- ---------- -------------------- ----------
E00001 MOBILE 10000 D00001 Bluetooth E00001
E00001 MOBILE 10000 D00001 Infrared E00001
E00001 MOBILE 10000 D00001 Bluetooth E00001
3 rows selected.
6. 10)Ascending order
select * from customer order by CNAME;
O/P:
CID CNAME CADDRESS
---------- -------------------- ------------------------------
C00001 Bharti Mumbai
C00002 Ena Pune
C00004 Krina Delhi
C00003 Nehal Banglore
C00005 Tina Mumbai
5 rows selected.
11)Descending Order
select * from customer order by CNAME desc;
O/P:
CID CNAME CADDRESS
---------- -------------------- ------------------------------
7. C00005 Tina Mumbai
C00003 Nehal Banglore
C00004 Krina Delhi
C00002 Ena Pune
C00001 Bharti Mumbai
5 rows selected.
12)Details about which customers interested in which department (use of using clause)
select CID,c.CNAME,c.CADDRESS,d.DID from customer c join cust_dept d using (CID);
O/P:
CID CNAME CADDRESS DID
---------- -------------------- ------------------------------ ----------
C00001 Bharti Mumbai D00001
C00002 Ena Pune D00001
C00003 Nehal Banglore D00002
C00004 Krina Delhi D00002
C00005 Tina Mumbai D00003
5 rows selected.
13)Customers interested in mobiles having connectivity='bluetooth'
8. select * from customer where CID in (Select CID from cust_dept where DID in (Select DID from
electronics where EID in(Select EID from mobile where connectivity='Bluetooth')));
O/P:
CID CNAME CADDRESS
---------- -------------------- ------------------------------
C00001 Bharti Mumbai
C00002 Ena Pune
2 rows selected.
14)Customers interested in biography section of books department
select * from customer where CID in (Select CID from cust_dept where DID in (Select DID from books
where BOOK_ID in (Select BOOK_ID from biography where TYPE='Freedom Fighter')));
O/P:
CID CNAME CADDRESS
---------- -------------------- ------------------------------
C00005 Tina Mumbai
9. 1 row selected.
15)Electronic items having cost > 10000
select * from electronics where ECOST > 10000
O/P:
EID ENAME ECOST DID
---------- -------------------- ---------- ----------
E00002 cameras 20000 D00001
E00003 TV 15000 D00001
2 rows selected.