SQL Assignment 2
SQL Assignment 2
Sailors
sid sname rating age
22 Kapila 7 45.0
29 Mahesh 1 33.0
31 Shiromi 8 55.5
32 Gihan 8 25.5
58 Mahen 10 35.0
64 Silva 7 35.0
71 Lalith 10 16.0
74 Dilshan 9 35.0
85 Nanda 3 25.5
95 Kalani 3 63.5
Boats
bid bname colour
Reserves
sid bid date
22 101 10/10/2013
22 102 10/10/2013
22 103 10/08/2013
22 104 10/07/2013
31 102 11/10/2013
31 103 11/06/2013
31 104 11/12/2013
64 101 09/05/2013
64 102 09/08/2013
74 103 09/08/2013
Q1. Select the names and ages of all sailors.
Q2. Find the names of sailors who have reserved at least one boat(Using Join).
Q4. Find the names of sailors who have reserved boat number 103.
Q6. Find the ages of sailors whose name begins and ends with B and has at least three
characters.
Q7. Find the names of sailors who have reserved a red or a green boat.
Q8. Find the names of sailors who have reserved red boats but not green
boats.
Q9. Find sids of sailors who have a rating of 10 or reserved boat 104.
Q10. Find the names of sailors who have reserved boat number 103
Q11. Find the names of sailors who have not reserved boat number 103
Q13. For each red boat find the number of reservations for this boat.
Q14. Find the names of sailors who are older than the oldest sailor with a rating of 10
Q15. Find the average age of sailors for each rating level that rating level
has at least two sailors.
Q16. Age of sailors who are above 30 years if that rating level has at least two such
sailors.
Used below SQL Joins Techniques to find most of
the answers
End of Assignment 2