Guest who paid highest charges in SQL

Guest who paid highest charges

 Write a query to display the guestid and guest name who was charged highest amount in the resort. Sort the output on the guestid.

Guest who paid highest charges in SQL
Guest who paid highest charges in SQL

SQL Code: Guest who paid highest charges Solution

select g.guestid, g.name
from guest g left join booking b
               on b.guestid=g.guestid
               where b.totalcharge=(select max(totalcharge) from booking)
   order by 1;

Related:

Leave a Comment

15 + 15 =