0% found this document useful (0 votes)
12 views

SQL Assignment 2

Uploaded by

Lakhan Sharma
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views

SQL Assignment 2

Uploaded by

Lakhan Sharma
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

SQL Assignment -2

Deadline – 15th July 2024

Using SQL that you are able to access,


1: create the following tables with appropriate constraints and insert
the data given below.
Sailors(sid: integer, sname: string, rating: integer,age: real)
Boats (bid: integer, bname: string, colour: string)
Reserves(sid: integer, bid: integer, day: date) date format "mm/dd/yyyy"

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

101 Interlake blue


102 Interlake red
103 Clipper green
104 Marine red

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).

Q3. Find all sailors with a rating above 7

Q4. Find the names of sailors who have reserved boat number 103.

Q5. Find the colours of boats reserved by “Silva”

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

Q12. Find the average age of sailors with a rating of 10

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

You might also like