Professional Documents
Culture Documents
DBMS Main File Dheeraj
DBMS Main File Dheeraj
Output:
TABLE 2
Code for creating table 2:
Output:
TABLE 3
Code for creating table 3:
Insert into
salesman_master(Salesman_No,Salesman_Name,Address_1,Address_2,City,Pincode,State,Salamt,Tgt_T
o_Get,Ytd_sales,Remarks)
Values ("S00001","Kiran","A/14","Worli","Bombay",400002,"MAH",3000,100,50,"Good");
Insert into
salesman_master(Salesman_No,Salesman_Name,Address_1,Address_2,City,Pincode,State,Salamt,Tgt_T
o_Get,Ytd_sales,Remarks)
Values ("S00002","Manish","65","Nariman","Bombay",400001,"MAH",3000,200,100,"Good");
Insert into
salesman_master(Salesman_No,Salesman_Name,Address_1,Address_2,City,Pincode,State,Salamt,Tgt_T
o_Get,Ytd_sales,Remarks)
Values ("S00003","Ravi","P-7","Bandra","Bombay",400032,"MAH",3000,200,100,"Good");
Insert into
salesman_master(Salesman_No,Salesman_Name,Address_1,Address_2,City,Pincode,State,Salamt,Tgt_T
o_Get,Ytd_sales,Remarks)
Values ("S00004","Ashish","A/5","Juhu","Bombay",400044,"MAH",3500,200,150,"Good");
Output:
TABLE 4
Code for creating table 4:
create table sales_order( S_Order_No varchar(10) not null primary key, S_Order_Date varchar(30),
Client_No varchar(20), Dely_Type varchar(10), Bill_Yn varchar(10), Salesman_No varchar(20), Dely_Date
varchar(25), Order_Status varchar(10), foreign key (Client_No) references client_master(Client_No),
foreign key (Salesman_No) references salesman_master(Salesman_No));
Output:
TABLE 5
Code for creating table 5:
Output:
TABLE 6
Code for creating table 6:
create table challan_header(Challan_No varchar(6) not null primary key, S_Order_No varchar(6),
Challan_Date varchar(10), Billed varchar(1), foreign key (S_Order_No) references sales_order
(S_Order_No));
insert into challan_header(Challan_No , S_Order_No , Challan_Date , Billed )
values ("CH9001", "O19001", "12-dec-95", "Y");
Output:
TABLE 7
Code for creating table 7:
Output:
Single Table Retrieval:
Code:
Code:
Question 3: Retrieve the list of names and the cities of all the clients.
Code:
Question 4: List the various products available from the product_master table.
Code:
Code:
Question 6: Find out the clients who stay in a city whose second letter is ’a’.
Code:
Question 7: Find the list of all clients who stay in city ‘Bombay’ or city ‘Delhi’ or city ‘Madras’.
Code:
select Name from Client_master where City = "Bombay" or City = "Delhi" or City = "Madras";
Question 8: List all the clients who are located in Bombay.
Code:
Question 9: Print the list of clients whose bal_due are greater than value 10000.
Code:
Question 10: Print the information from sales_order table of orders placed in the month of January.
Code:
Question 11: Display the order information for client_no 'C00001' and 'C00002.
Code:
Code:
Select Product_No, Description from Product_master where Description in('1.44 Drive', '1.22 Drive');
Question 13: Find the products whose selling price is greater than 2000 and less than or equal to 5000
Code:
select Product_No , Description from Product_master where Sell_Price > 2000 and Sell_Price <= 5000;
Question 14: Find the products whose price is more than 1500 and also find the new selling price as
original selling price * 15.
Code:
select Product_No , Description, (Sell_Price * 15) New_sell_price from Product_master where Sell_Price
> 1500;
Question 15: Rename the new column in the above query as new_price.
Code:
select Product_No , Description, (Sell_Price * 15) New_price from Product_master where Sell_Price >
1500;
Question 16: Find the products whose cost price is less than 1500.
Code
Code:
Code
Question 19: Divide the cost of product ‘540 HDD’ by difference between its price and 100.
Code
Code
select name, city, state from client_master where state not in ('Maharashtra');
Question 21: List the product_no, description, sell_price of products whose description begin with
letter ‘M’.
Code
select product_no, description, sell_price from product_master where description like 'M%';
Question 22: List all the orders that were canceled in the month of March.
Code
Code:
Code:
Code:
Question 26: Determine the maximum and minimum product prices. Rename the title as max_price
and min_price respectively.
Code:
Code:
Question 28: Find all the products whose qty_on_hand is less than reorder level.
Code:
Question 29: Print the information of client_master, product_master, sales_order table in the
following format for all the records {cust_name} has placed order {order_no} on {s_order_date}.
Code:
select concat(cm.Name, ' has placed order ', so.S_Order_NO, ' on ', so.S_Order_Date) information
Question 30: Print the description and total qty sold for each product.
Code:
Code:
Question 32: Calculate the average qty sold for each client that has a maximum order value of
15000.00.
Code:
Question 33: Find out the total sales amount receivable for the month of jan. It will be the sum total
of all the billed orders for the month
Code:
Question 34: Print the information of product_master, order_detail table in the following format for
all the records:- {description} worth Rs. {total sales for the product} was sold.
Code:
select concat(pm.Description, ' worth Rs. ', sum(sod.Qty_Disp * sod.Product_Rate), ' was sold. ' ) info
group by pm.Product_No;
Joins and Correlations:
Question 36: Find out the products which has been sold to ‘Ivan Bayross’.
Code:
Question 37: Find out the products and their quantities that will have to delivered in the current
month.
Code:
group by sod.Product_No;
Question 39: Find the names of clients who have purchased 'CD Drive.
Code:
Question 40: List the product no and s Order no of customers having qty ordered less than 5 from the
order details Table lor the product '1.44 Floppies’.
Code:
Question 41: . Find the products and their quantities for the orders placed by 'Vandana Saitwal’ and
‘Ivan Bayross'.
Code:
Question 42: Find the products and their quantities for the orders placed by client_no 'C00001' and
‘CO0002'
Code:
select cm.Client_No, sod.Product_No, sod.Qty_Disp
Code
Question 45: Find the client names who have placed orders before the month of May, 96.
Code:
where Client_No in (select distinct Client_No from sales_order where month(S_Order_Date) < 5);
Question 46: Find out if product '1.44 Drive' is ordered by any client and print the client_no, name to
whom it is was sold.
Code
Code
Question 48: Display the order number and day on which clients placed their order.
Code
Question 49: Display the month (in alphabets) and date when the order must be delivered.
Code
Question 52: Find the number of days elapsed between today's date and the delivery date of the
orders placed by the clients.
Code
Code
Question 54: Change the selling price of"1.44 Floppy Drive' to Rs. 1150.00.
Code
Queston 55: Delete the record with order number 'O19001' from the order table.
Code
Code:
Questin 58: Change the delivery date of order number 'O10008' to 16-08-96.
Code:
Code:
Question 60: Change the cost price of'1.22 Floppy Drive' to Rs. 950.00.
Code: