0% found this document useful (0 votes)
185 views9 pages

Practical - 3 PDF

The document contains solutions to 18 SQL queries on various database tables like client_master, sales_order, and product_master. The queries find specific records based on conditions, perform calculations on columns, count records, and create new tables from existing ones.

Uploaded by

YASH MODI
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
185 views9 pages

Practical - 3 PDF

The document contains solutions to 18 SQL queries on various database tables like client_master, sales_order, and product_master. The queries find specific records based on conditions, perform calculations on columns, count records, and create new tables from existing ones.

Uploaded by

YASH MODI
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 9

DBMS

PRACTICAL - 3

1. Find the name of all clients having ‘a ‘ as the second letter in their
names.
Ans :- select name from client_master where name like '_a%';

2. Find out the clients whose name is four character ling and second
letter is ‘a‘.
Ans :- select name from client_master where name like '_a%__';

3. Find out the name of city whose second last character is ‘a’.
1
DBMS

Ans :- select city from client_master where city like '%a_';

4. Print the list of clients whose bal_due is greater than or equal to


10000.
Ans :- select Name from client_master where Bal_due>=1000;

5. Print the information from sales_order table for orders placed in


the month of January.
Ans :- select * from sales_order where Order_date like '%-01-__';

2
DBMS

6. Display the order information for client_no ‘C003’ and ‘C001’.


Ans :- select * from sales_order where client_no='C001' or 'C003';

7. Find products whose selling price is greater than 2000 and less
than or equal to 5000.
Ans :- select Descriptio from product_master where
Sell_price<=5000 and Sell_price>2000;

3
DBMS

8. Find products whose selling price is more than 1500. Calculate a


new selling price as, original selling price * .15. Rename the new
column in the above query as new_price.
Ans :- select count(*) from product_master where
Sell_price>=1500;

9. List the names, city and state of clients who are not in the state of
‘Maharashtra’.
Ans :- select Name, City, State from client_master where
State!='Maharashtra';
4
DBMS

10. Count the total number of orders.


Ans :- select count(*)"Total" from sales_order;

11. Calculate the average price of all products.


Ans :- select AVG(Cost_price) Average from product_master;

5
DBMS

12. Determine the maximum and minimum product prices.


Rename the output as max_price and min_price respectively.
Ans :- select max(Sell_price) 'max_price',min(Sell_price)
'min_price' from product_master;

13. Count the number of products having price greater than or


equal to 1500.
Ans :- select count(*) from product_master where
Sell_price>=1500;

6
DBMS

14. Find all the products whose qty_on_hand is less than


reorder level.
Ans :- select Description from product_master where
QTY_on_hand>Reoder_lvl;

15. Create table cmaster from client_master table.


Ans :- create table cmaster as select * from client_master;

7
DBMS

16. Insert data in cmaster from client_master where


city=’bombay’.
Ans :- insert into cmaster select * from client_master where
City='Bombay';

17. Create table sales from sales_order with order_no and


client_no columns.
Ans :- create table sales(order_no varchar(6), client_no varchar(6))
as select Order_no,Client_no from sales_order;

8
DBMS

18. Insert data in sales from sales_order table.


Ans :- create table sales as select * from sales_order;

You might also like