Tutorial_5_Question_paper_of_SQL_exercise
Tutorial_5_Question_paper_of_SQL_exercise
2024 – 2025
SQL exercises
This exercise uses the following schema.
Restaurant (restaurant_id, name))
Simple queries
1. List the name, the number of branches, and the average number of seats of all
restaurants, order by the restaurant name.
2. List the name and location of all fast food joints (category “Fast Food”), order the list by
the restaurant name and then by the branch location.
3. Find the members whose name starts with ‘A’ or ‘E’. List the results by showing the
member name and the birthday, order by the member name.
4. Find all restaurant branches located in the central (i.e., location with “Central”), list only
the restaurant name, the branch location, and the number of seats. Order the list by the
number of seats, then by the location. Show only the first 2 results.
Insert/delete queries
5. Add 10 points per year joined to every member. The current year is 2025. For example, if
a member joined in year 2010, 150 points should be added. (The joined field stores the
year the member joined the membership)
6. Insert a new member whose name is “Albert B. Carter” and born on “1985-07-25”, with
100 points, with member_id equals 300, joined the membership in year 2018.
Complex queries
8. Find all branches with at least one visit scoring less than 4. List the restaurant name, the
branch location, and the best score among the visits to the branch. Order the list by the
restaurant name, and then the location.
9. Find all members who has visited the restaurant branch(/branches) that received the
lowest average score ever. Show only the member name, order by the member name.
10. Find all members who have made at least two visits, show only the member name, the
name of the restaurant of the member’s first visit, and that of the last visit. Show any of
the restaurant names if the member visited more than one restaurant on the same day.
Order the list by the member name. Show only the first 5 results.
11. Count the number of unique members visiting each of the restaurants. List the result by
showing the restaurant name, and the number of members. A restaurant should be
listed even if it is not visited by any member, in that case the count should be zero. Order
the list by the number of unique members (descending), then by restaurant name.