Structure Query Language, C programming, Java, Servlet, Jsp, Unix

Friday 30 March 2012

Nested Queries.


1) find the product_no and description of non-moving products(eg.products not being sold).

select product_no,description from product_master
where product_no not in(select product_no from sales_order_details);

2) Find the customers name,address1,address2,city and pincode for the client who has placed order no "O19001'.

select name,address1,address2,city,pincode from client_master
where client_no in (select client_no from sales_order
where s_order_no='O19001');

3) Find the client name who have placed order before the month of may,96.

select client_no,name from client_master where client_no in(select client_no from sales_order 
where to_char(s_order_date,'mon,yy')<'may,96');

4) Find out if product "1.44 Drive" is ordered by any client and print client_no name to whom it was sold.

select client_no,name from client_master where client_no
in (select client_no from sales_order where s_order_no in (select s_order_no 
from sales_order_details where product_no in(select product_no 
from product_master where description='1.44 Drive')));

5) Find the name of clients who have placed ordered worth RS. 10000 or more.

select name from client_master where client_no in(select client_no from sales_order
where s_order_no in (select s_order_no from sales_order_details
where (qty_ordered*product_rate)>=10000));



No comments:

Post a Comment