Practical File Queries - HHW
Practical File Queries - HHW
MySQL Queries
1. Create a student table with the student id, name, class, date of birth, section
and marks as attributes where the student id is the primary key.
2. Insert the details of a new student in the above table.
3. Delete the details of a particular student whose id is 5, from the above table.
4. Use the select command to get the details of the students with marks more
than 80.
5. Get the student name and marks, class of the students whose name are of at
least 6 characters long and starting with letter ‘A’.
6. Display students’ details of all students who are born in the year 2000.
7. Display students’ names, class, section who are born in month of ‘June’, also
sort them in the descending order of class, within same their names should dis-
play in alphabetical order.
8. Display student id, name and percentage (assuming marks are out of 40).
9. Increase marks of all students by 2%.
10.Add one more column in the above table result, storing values ‘P’ for pass and
‘F’ for fail.
11. Write SQL commands to create above tables with foreign keys and primary
keys in tables mentioned below:
Order Table: (order ID (PK), cust_ id (FK), product id (FK) and order Date) by
joining two tables Product: (product id (PK), description, quantity, unit price)
and Customer: (customer ID (PK), customer Name, contact No, country).
12. Display order ID, customer Name, and order Date by joining two tables Order
and Customer.
13. Find the total number of customers from each country along with country
name.
14. Display order id, customer name, description and unit price of all orders.
15. Display order date, customer name, unit price for all orders which are placed
after 01-01-2020 in reverse chronological order of order date.
16. Display order id and description of products all products ordered from “India”.
17. Display no of customers from “India” who had placed the order before 06-01-
2020.
18. Display total sale made for each product along with description of products.
19. Display order id, product id, unit price and order date of all orders whose unit
price is greater than unit price of product “P01”.
20. Display structure of all tables (Order, Product, and Customer) along with their
constraints.
Note: Write the answers of these queries in your register and submit after summer break.