Practical
Practical
b) Observe the following tables customers and orders and write queries
given below:
Table – Customer
CustomerID CustomerName City MobileNo
C111 Abhishek Ahmedabad 9999999999
C132 Bhavik Anand 7799779977
C135 Chandani Baroda 8856895485
C145 Dhara Ahmedabad 7456879652
C121 Divya Anand 9015123569
Table - Order
OrderID OrderDate OrderAmt CustomerID
O111 2022-04-15 1500 C111
O112 2022-05-20 1800 C121
O113 2022-05-31 1000 C199
O131 2022-06-12 1400 C135
(i) Display CustomerID, CustomerName and order amount for customers belongs to
Ahmedabad.
(ii) Display the order details in descending order of amount.
(iii) Display OrderId, Orderdate , customername and mobileno of customers whose
name ends with ‘k’ and name contains letter ‘h’.
(iv) Display the sum of order amount for each city.
(i) Write command to add primary key and foreign key in tables using alter.
(ii) Increase the price of all computer books by 70.
(iii) Display the book id, book name and quantity issued for all books which have
been issued.
(iv) Display the book id, book name, author name, quantity issued for all books
which price are 200 to 400.
b) Create the table "weather" as given below, take data type and size yourself and
insert all records.
Answer the following sql queries.
Cid City MaxTemp MinTemp Rainfall
C01 Delhi 40.0 32.0 24.1
C02 Bengaluru 31.0 25.0 36.2
C03 Chennai 35.0 27.0 40.8
C04 Mumbai 29.0 21.0 35.2
C05 Kolkata 39.0 23.0 41.8
C06 Allahabad 41.0 30.0 32.4
Q – 1 a) Write a program to create CSV file and store empno, name and salary of employee.
Display the records whose salary in range of 5000 to 15000.
b) Consider the above table as "POP" and first column is 'COUNTRY' as primary key.
Answer the following sql queries.