Download as DOCX, PDF, TXT or read online from Scribd
Download as docx, pdf, or txt
You are on page 1of 2
RDBMS Practical 5
Implement SQL query based on various function.
1. Create table name product_master, Data are :- pro_id, pro_name, sell_price, cost_price, profit_per, Reorder level. Ans 1: create table product_master(pro_id varchar2(5),pro_name varchar2(30),sell_price number(6,2),cost_price number(6,2),profit_per number(5,2),reorder_level number(3)); 2. Create table name salesman_master, Data are :- s_id, s_name, address1, city, pincode, sales_amt, DOJ Ans 2: create table salesman_master (s_id varchar2(5), s_name varchar2(15),address1 varchar2(30),city varchar2(15),state varchar2(10),pincode number(6),sales_amt number(10),doj date); List of queries to be performed :- 1. List all the product whose value (sell_price) is less than 500 ₹. Ans : select pro_id, pro_name from product_master where sell_price <=500; 2. Add salary field in a salesman_master table. Ans: alter table salesman_master add (salary number(10)); 3. Display total no. of product. Ans: select count(pro_id) ” totol product” from product_master; 4. Display total no. of salesman. Ans: select count(s_id) “Total salesman” from salesman_master 5. List product with minimum sell price & maximum sell price and rename output as minimum price & maximum price. Ans: select min(sell_price) “Minimum price”, max(maximum price) from pro_master; 6. Display cost price in a rounding value. Ans: select round(cost_price) from pro_master; 7. Display total salary of all salesman. Ans: select sum(salary) “total salary ” from salesman_master; 8. Display average salary of all the salesman. Ans : select avg(salary)”average salary” from salesman_master; 9. List name, city & state of the salesman who are not belong to Gujarat & Maharashtra. Ans: select s_id, s_name , city , state from salesman_master where state not in (‘Gujarat’, ‘Maharastra’); 10. List product whose price is more than 1000 & increment the sales price by 10 %. Mention old price and new price.
“Updated price ”from pro_master where sell_price >=10000; 11. Display salesman name in upper leader, lower leader and statement case. Ans: select upper(s_name), lower(s_name),initcap(s_name) from salesman_master; 12. Display sales_amt form product master & id by padding * for each price. Ans: select rpad(pro_id,*,7),lpad(sales_amt) from pro_master; 13. Select first 5 character of product name from product_master table. Ans: select substr(pro_name, 0,5) from pro_master; 14. Display all salesman who are joining after March 2020. Ans: select s_name from salesman_master where to_char(doj,’mm’)>03 and to_char(doj,yyyy)>=2020; 15. Remove unwanted character from product description. Ans select ltrim(pro_name,’pro’) from pro_master;