Dbms
Dbms
Dbms
Table created.
Table created.
Table created.
10 rows selected.
2. Give all the information about all the customer with salesman
number 1001.
5. List snum of all salesmen with order in order table without any
duplicates.
SNUM
---------
1001
1002
1003
1004
1007
7 rows selected.
7. List of name & cities of all salesmen in London with commission
above 10%.
SNAME CITY
-------------------- --------------------
Piyush London
Mit London
8. List all customers excluding those with rating < 10 unless they
are located in Rome.
SQL> select * from customers where rating >= 10 and city != 'Rome';
9. List all orders for more than Rs.100 except the order of snum<100
of 10/03/97.
SQL> select * from orders where amount > 100 and snum >=100 and odate !
= '10-mar-97';
8 rows selected.
10. List all orders taken on October 3rd or 4th or 6th 2006.
no rows selected
11. List all customers whose name begins with letter 'C'.
12. List all customers whose name begin with letter ‘A’ to 'G'.
SQL> select * from customers where cname between 'A%' and 'G%';
no rows selected
14. Find out the largest order of salesman 1002 and 1007.
MAX(AMOUNT) SNUM
----------- ---------
5160.45 1002
1098.06 1007
COUNT(ONUM)
-----------
0
SUM(AMOUNT)
-----------
26658.3
AVG(AMOUNT)
-----------
2665.83
no rows selected
19. Find the largest orders take by each salesman of each date.
SNUM MAX(AMOUNT)
--------- -----------
1001 9891.88
1002 5160.45
1003 1713.23
1004 1900.1
1007 1098.06
20. Find the largest order take by each salesman of 10/03/2006.
SNUM MAX(AMOUNT)
--------- -----------
1001 767.19
1002 5160.45
1004 1900.1
1007 1098.06
21. Count the no of different not NUL cities in the Customer table.
COUNT(CITY)
-----------
7
MIN(AMOUNT) CNUM
----------- ---------
767.19 2001
1713.23 2002
5160.45 2003
75.75 2004
4723 2006
1900.1 2007
18.69 2008
7 rows selected.
23. Find out first customer in alphabetical order whose name begins
with 'G'.
COUNT(SNUM) ODATE
----------- ---------
5 10-MAR-06
2 10-APR-06
1 10-MAY-06
2 10-JUN-06
26. Display the no of orders for each day in the descending order of
the no of orders in the following format.
FOR dd-mon-yy, there are _ Orders.
ODATE COUNT(ONUM)
--------- -----------
10-MAR-06 5
10-APR-06 2
10-JUN-06 2
10-MAY-06 1
CITY MAX(RATING)
-------------------- -----------
Bombay 300
London 100
Rome 200
Surat 300
7 rows selected.
30. Calculate the total of order for each day an place the result in
descending order.
SUM(AMOUNT) ODATE
----------- ---------
11201.83 10-JUN-06
8944.49 10-MAR-06
4723 10-MAY-06
1788.98 10-APR-06
31. Show the name of all customer with their salesman's name.
CNAME SNAME
-------------------- --------------------
Harsh Piyush
Gita Anand
Lalit Sejal
Govind Sejal
Chirag Piyush
Chinmay Rajesh
Pratik Mit
7 rows selected.
32. List all customer and salesmen who share same city.
6 rows selected.
33. List all order with the name of their customer and salesman.
10 rows selected.
34. List all order by the customer no locate in the same city as
their salesman.
37. Find all pair of customer having the same rating without
duplication.
SQL> select customers.*,salesmen.sname from customers,salesmen where
salesmen.sname = 'Sejal' and salesmen.snum = customers.snum;
CNUM CNAME CITY RATING SNUM SNAME
2003 Lalit Surat 200 1002 Sejal
2004 Govind Bombay 300 1002 Sejal
40. Find all pair of customer served by a single salesmen with the
salesman's name and no.
41. List all salesmen who are living in the same city with out
duplicate rows.
42. List all pairs of order by a given customer with customer name.
43. Produce the name and city of all the customer with the same
rating as Harsh.
SQL> select cname,city from customers where rating = (select rating from customers
where cname = 'Harsh') and cname!= 'Harsh' ;
CNAME CITY
-------------------- --------------------
Chirag London
Pratik Rome