Mysql Join Assignment
Mysql Join Assignment
Mysql Join Assignment
In a database create the following tables with suitable constraints. Create Table Command
Tutorial
Table : STUDENT
+------------+------------------+----------+----+---------+-----
----------------+--------------------+
+------------+------------------+----------+----+---------+-----
----------------+--------------------+
+-------+----------------+-------+------+------+----------------
--------+----------------------------+
Table : SPORTS
+---------------+-----------------------+-----------------------
+---------------+
+---------------+---==========----------+-----------------------
+---------------+
Q1. Display the lowest and the highest classes from the table STUDENTS.
Q2. Display the number of students in each class from the table STUDENTS.
Q5. Display the Admission number, name, class, section, and roll number of the students
whose grade in the Sports table is ‘A’.
Q6. Display the name and phone number of the students of class 12 who are playing some
game.
Q8. Display the names and phone numbers of the students whose grade is ‘A’ and whose
coach is Narendra.
Q9. Identify the Foreign Keys (if any) of these tables. Justify your choices
Q10. Predict the output of each of the following SQL statements, and then verify the output
by actually entering these statements
Table : ITEMS
+--------+--------------+---------------+---------------+
+--------+--------------+---------------+---------------+
+--------+--------------+---------------+---------------+
Table : BILLS
+---------------+-----------------------+---------------+---------------+
+---------------+-----------------------+---------------+---------------+
| 1 | 2010-04-01 | 1002 | 2 |
| 1 | 2010-04-01 | 3001 | 1 |
| 2 | 2010-04-01 | 1001 | 3 |
| 2 | 2010-04-01 | 1002 | 1 |
| 2 | 2010-04-01 | 2003 | 2 |
| 3 | 2010-04-02 | 2002 | 1 |
| 4 | 2010-04-02 | 2002 | 4 |
| 4 | 2010-04-02 | 2003 | 2 |
| 5 | 2010-04-03 | 2003 | 2 |
| 5 | 2010-04-03 | 3001 | 1 |
| 5 | 2010-04-03 | 3002 | 3 |
+---------------+-----------------------+---------------+---------------+
Q14. Display total quantity of each item sold but don’t display this data for the items whose
total quantity sold is less than 3.
Q15. Display the details of bill records along with the Name of each corresponding item.
Q16. Display the details of the bill records for which the item is ‘Dosa’.
Q17. Display the bill records for each Italian item sold.
Q18. Display the total value of items sold for each bill.
In a database create the following Tables with suitable constraints.
Table : VEHICLE
+---------+-------------+--------+-------+---------+-------+
+---------+-------------+--------+-------+---------+-------+
+---------+-------------+--------+-------+---------+-------+
Table : CHALAAN
+------------+----------+------+--------+---------+-------+
+------------+----------+------+--------+---------+-------+
+------------+----------+------+--------+---------+-------+
Table : OFFENCE
+---------------+----------------+------+-------+---------+-------+
+---------------+----------------+------+-------+---------+-------+
+--------------+-----------------+------+-------+---------+-------+
Q19. Display the dates of first registration and last registration from the table Vehicle.
Q21. Display the total number of challans issued for each offence.
Q22. Display the total number of vehicles for which the 3rd and 4th characters of RegNo are
‘6C’.
Q23. Display the total value of challans issued for which the Off_Desc is ‘Driving without
License’.
Q24. Display details of the challans issued on ‘2010-04-03’ along with Off_Desc for each
challan.
Q25. Display the RegNo of all vehicles which have been challaned more than once.
Q26. Display details of each challan along with vehicle details, Off_desc, and Challan_Amt