Number of Tickets Booked in SQL

Question:

Number of Tickets Booked

Write query to display user id and number of tickets booked by each user. Give an alias name as no_of_tickets. Sort the result based on number of tickets booked. (hint: Use Tickets table and users table)

Number of Tickets Booked

Code:

Main.sql

select user_id, count(ticket_id) as no_of_tickets
from tickets
group by user_id
order by no_of_tickets;

Recommended:

Leave a Comment

Your email address will not be published. Required fields are marked *

x