Forum

Write a query to di...
 
Notifications
Clear all

Write a query to display the guest id and guest name who has charged the highest amount in the resort. sort the output on the guest id.


Rahul Updhyay
Posts: 17
Topic starter
(@rahul)
Active Member
Joined: 1 year ago

Write a query to display the guest id and guest name who has charged the highest amount in the resort. sort the output on the guest id.

2 Replies
Deepak Raj
Posts: 18
 Deepak Raj
(@Deepak Raj)
Joined: 1 year ago

Hello,

Try the below query and let me know.

 

Select GuestID, name

from Guest

Where

Guest.GuestID IN(Select GuestID from Booking where totalcharge=select max(totalcharge)

from Booking Group by GuestId)

Order By guestID desc

 

Reply
SQL Admin
Posts: 6
Admin
(@sql-admin)
Member
Joined: 1 year ago

Display guest details who paid total charges rs.50000 and above. write a query to fetch guest id, guest name, and the sum of total charges. give alias name to total charges as total paid. sort the result by guest id.

Select
GuestID,
GuestName,
SUM(Total_Charges) as TotalPaid
From
Guest
Group By GuestID, GuestName
Having SUM(Total_Charges)>= 50000
Order GuestID DESC

Reply
Share: