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

Friday, 30 March 2012

Single Table Retrival.


1) Find out the names of all clients.

select name from client_master ;

2) print the entire client_master table.

select * from client_master ;

3) Retrieve the list of names and the cities of all the clients.

select name,city from client_master;

4) List the various products available from the product_master.

select product_no,description from product_master ;

5) Find the name of all clients having 'a' as the second letter in their names.

select name from client_master where name like '_a%' ;

6) Find out the clients who stay in city whose second letter is 'a' .

select name,city from client_master where city like '_a%' ;

7) Find the list of all clients who stay in bombay or city delhi or city madras.

select name,city from client_master where city like '_a%' ;

8) List all the clients who are  located in 'Bombay'.

select name,city  from client_master where city in('Bombay','Delhi','Madras');

9) Print the list of clients whose bal_due are greater than value 10000

select name,city from client_master where city = 'Bombay' ;

10) Print the information from sales_order table of order placed in month of january.

select name,bal_due from client_master where bal_due > 10000 ;

11) Display order information for client_no 'c00001' and 'c00002' ;

select s_order_no,s_order_date from sales_order where s_order_date in

12) Find the products with description as '1.44 drive' and '1.22 drive' .

select s_order_no,s_order_date from sales_order where s_order_date in
(select s_order_date from sales_order where to_char(s_order_date,'mon')='jan');

14) Find the  product whose selling price is more than 1500 and also find the new selling price as original price * 15

select s_order_no,client_no,s_order_date from sales_order where client_no in('C00001','C00002');

15) Rename the new in the above query as new_price

select product_no||''''|| description||'''' from product_master ;

16) Find the product whose cost price is less than 1500

select product_no,description,sell_price from product_master where sell_price >2000 and sell_price<=5000 ;

17) List the product in sorted order of their description

select product_no,description,sell_price,sell_price * 15  "NEW_PRICE" from product_master where sell_price >1500 ;

18) Calculate the square root of price of each product.

select product_no,description,sqrt(cost_price)"root" from product_master ;

19) Divide the cost of product '540 HDD' by difference between its price and 100.

select cost_price/(cost_price-100)"Diff" from product_master where description = '540 HDD' ;

20) List the names,city,state of clients not in the state of 'Maharashtra' .

select name,city,state from client_master where state <> 'Maharashtra' ;

21) List the product_no,description,sell_price of products whose description begin with letter 'M' .

select product_no,description,sell_price from product_master where description like 'M%' ;

22) List of all orders that were canceled in month of March.

select s_order_no,order_status,s_order_date from sales_order where to_char(s_order_date,'mon')='mar' and order_status='c';

No comments:

Post a Comment