Uploaded by Ayesha Ajmal

Lab quiz 1 (sec A)

advertisement
Database System (Sec A)
Quiz 1 (Lab)
Table 1 Order
ord_no
70001
70009
70002
70004
70007
70005
70010
70003
70011
70013
purch_amt
150.5
270.65
65.26
110.5
948.5
2400.6
1983.43
2480.4
75.29
3045.6
ord_date
2012-10-05
2012-09-10
2012-10-05
2012-08-17
2012-09-10
2012-07-27
2012-10-10
2012-06-27
2012-08-17
2012-04-25
customer_id
3005
3001
3002
3009
3005
3007
3009
3008
3003
3002
salesman_id
5002
5005
5001
5003
5002
5001
5003
5002
5007
5001
Solve the below SQL queries and show the output as well.
1- write a SQL query to find the highest purchase amount on '2012-08-17' by each salesperson.
Return salesperson ID, purchase amount. [2 Marks]
2- write a SQL query to find the maximum order (purchase) amount in the range 2000, 6000 (Begin
and end values are included.) by combination of each customer and order date. Return
customer id, order date and maximum purchase amount. [2 Marks]
3- write a SQL query to find details of all order where purchase amount less than 200 or excluding
combination of order date greater than or equal to '2012-02-10' and customer ID less than
3009. Return ord_no, purch_amt, ord_date, customer_id and salesman_id. [3 Marks]
Database System (Sec A)
Quiz 1 (Lab)
Table 2 Customer
4- Consider the Table 2 and write sql query to retrieve the customers whose last name starts with
the letter t and ends with the letter s. [3 Marks]
Download