You are on page 1of 4

Make tables with the following structures : Client_Master : Field ClientNo name City Pincode State BalDue Type

int(11) varchar(2 varchar(2 0) int(11) 0) varchar(2 int(11) 0) Nul NO l NO NO NO YES NO Ke PR y I Defa NULL ult Extra Auto_increme nt

NULL

Product_Master: Field ProductNo Description Profit_Percen Unit_Measur t QtyOnHand e RecorderLvl SellPrice Costprice Type int(11) varchar(2 Float(15) 0) int(11) int(11) int(11) Float(15) Float(15) Nul NO l NO NO NO NO NO NO NO Ke PR y I Defa NULL ult Extra Auto_increme nt

NULL

Insert the following values in the above tables: Client_Master :

ClientNo 1 2 3

Name Ivan Mamta Chhaya

City Mumbai Madras Mumbai

Pincode 400054 780001 400057

State Maharastra Tamil Nadu Maharastra

BalDue 15000 0 5000

4 5 6

Ashwini Hansel Deepak

Bangalore Mumbai Mangalore

560001 400060 560050

Karnataka Maharastra Karnataka

0 2000 0

Product_Master: Product No 1 2 3 4 5 6 7 8 9 Descripti on T_Shirts Shirts C_Jeans Jeans Trousers Pull Over D_Shirts Lycra Tops Skirts Profit_Perce nt 5 6 5 5 2 2.5 4 5 5 Unit_Measu re Piece Piece Piece Piece Piece Piece Piece Piece Piece QtyOnHa nd 200 150 100 100 150 80 100 70 75 Recorder Lvl 50 50 20 20 50 30 40 30 300 SellPri ce 350 500 600 750 850 700 350 300 450 Costpri ce 250 350 450 500 550 450 250 175 300

Salesman_Master: SM_no S0001 S0002 S0003 S0004 Name Aman Omka r Raj Ashis h Add 1 A/1 4 65 P-7 A/5 Add 2 Worli Narim an City Mumb ai Mumb ai Pincod State e 40000 2 40000 1 40003 2 40004 4 Maharastra Maharastra Maharastra Maharastra Sale_a mt 3000 3000 3000 3500 T_sale Left_sal s es 100 200 200 200 50 100 100 150 Remark s Good Good Good Good

Bandra Mumb ai Juhu Mumb ai

Sales_order:

Order_n o 019001 019002 046865 019003 046866 019008

ClientNo 1 2 3 1 4 5

Orderdat SM_no e 12-0611 25-0611 18-0211 03-0411 20-0511 24-0511 S0001 S0002 S0003 S0001 S0002 S0004

DelyTyp e Free Paid Free Free Paid Free

DelyDat e 20-0711 27-0611 20-0211 07-0411 22-0511 06-0711

OrderStat us In process Cancelled Fulfilled Fulfilled Cancelled In process

Sales_order_details:

OrderNo 019001 019001 019001 019002 046865 046865 046865 046865 019003 019003 046866 046866 019008

ProductNo 1 5 6 1 8 5 1 5 3 4 6 9 1

QtyOrdered 4 2 2 10 3 3 10 4 2 1 1 1 10

QtyDisp 4 1 1 0 3 1 10 4 0 1 0 0 5

ProductRate 525 8400 5250 525 3150 5250 525 1050 1050 12000 8400 1050 525

019008

1050

Write the SQL queries for the following: 1. 2. 3. 4. 5. 6. Find out the names of all clients. Retrive the entire contents of the client_master table. List the various products available from the Product_Master table. Change the city of clientNo C005 to Banglore. Change the BalDue of ClientNo C001 to Rs.1000. Add column name called Telephone of data type number and size=10 to the client_Master table. 7. List of all the names of all clients having a as second letter in their names. 8. List of clients who stay in a city whose first letter M. 9. List of all clients who stay in bangalore or mangalore. 10.List of all clients whose BalDue is greater than 1000. 11.Display the information from Sales_order table for the orders placed in month of june. 12.Display the order information of ClientNo C0001 and C0002. 13.List products whose selling price is greater than 500 and less than or equal to 750. 14.List the names, city and state of clients who are not in the state of Maharastra. 15.Count the total number of orders. 16.Calculate the average price of all products. 17.Determine the maximum and minimum price for the product prices. 18.Count the number of products having price greater than or equal to 500. 19.Display the order number and day on which clients placed their orders. 20.Display the month and date when the order must be delivered. 21.Find the date, 25 days after todays date. 22.Display the description and total quantity sold for each product. 23.Display the product which has been sold to Ivan. 24.Find the names of clients who have purchased Trousers. 25.Display the name and complete address for the customer who has placed order number019001.