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

Sailors Schema Instance Queries

This document provides 30 SQL queries to practice on sample relations for sailors and boat reservations. The queries cover a range of selection, aggregation, sorting, comparison, and update operations on the relations. Some examples include retrieving sailor names in descending order, finding sailors who reserved a specific boat, finding the youngest sailor, and calculating averages by rating level.

Uploaded by

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

Sailors Schema Instance Queries

This document provides 30 SQL queries to practice on sample relations for sailors and boat reservations. The queries cover a range of selection, aggregation, sorting, comparison, and update operations on the relations. Some examples include retrieving sailor names in descending order, finding sailors who reserved a specific boat, finding the youngest sailor, and calculating averages by rating level.

Uploaded by

n200886
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Lab Questions for CSE 3 and CSE4 (SQL)

G.JAYA KRISHNA

Create the Relations according to the given schema and insert the following data:

Write the queries for the following?


1. Display the Names of sailors in Descending order.
2. Retrieve the Names of sailors who reserved boat number 103.
3. Retrieve the youngest sailor from sailor table.
4. Retrieve the distinct color of boats.
5. Find the colors of boats reserved by Sehwag.
6. Retrieve sname,sid of sailors who have a rating of atleast 8 or reserved a boat 103.
7. Find the names of sailors who have reserved atleast two boats.
8. Find the names of sailors who have not reserved a boat whose name contains the string
“hi”, order the names in ascending order.
9. Find the sailor ids of sailors with age over 35 and who have not reserved a boat whose
name includes the string “%lin%”.
10. Find the names of sailors who have reserved all boats.
11. Find the sids of sailors who have reserved a red not a green boat (Using normal
procedure, Using Exists and not exists).
12. Find the names of sailors who have reserved red and green boat (Using normal
procedure, Using IN operator)?
Lab Questions for CSE 3 and CSE4 (SQL)
G.JAYA KRISHNA

13. Find the sailor ids of sailors whose rating is better than some sailor called Watson.
14. Find the sailor ids of sailor whose rating is better than all sailors who reserved a boat
104.
15. For each rating find the average age of sailors at that level of rating.
16. For each boat which was reserved by at least 2 distinct sailors find the boat id and the
average age of sailors who reserved it.
17. Find the sum, Max, Min, Average age of sailors.
18. Retrieve the youngest sailor details for each rating level?
19. Retrieve the names of Sailors who have reserved either boat number 102 or 104.
20. For each INS boat find the number of reservations for that boat.
21. Display the total number of sailors reserved by each boat.
22. Find the average age of sailors for each rating level that has at least two sailors.
23. Retrieve the number of sailors, total salary of sailors for each rating level which should
have at least 2 such sailors?
24. Print the details of sailors whose name length is more than 3 characters.
25. Increase the rating of Sailors by 20% whose rating is less than 5.
26. Find the name and age of sailors whose names starts with “M” and ends with “A” and
has at least three characters.
27. Display distinct age of sailors whose rating is between 5 and 9.
28. Retrieve the names of 4 sailors who have highest rating.
29. Find age of the youngest sailor with age >=18 for each rating with at least 2 sailors.
30. Change the reserved date of boats by adding three days to current date and boat name
contains “INS” as a substring and reserved by more than or equal to 2 sailors.

You might also like