Forum

Write a query to di...
 
Share:
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.


Posts: 17
Topic starter
(@rahul)
Active Member
Joined: 4 years 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
Posts: 18
Guest
(@Deepak Raj)
Active Member
Joined: 4 years 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

Self Learning Video Tutorials - Software Course

Posts: 10
Admin
(@sql-admin)
Active Member
Joined: 4 years 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

Leave a reply

Author Name

Author Email

Title *

 
Preview 0 Revisions Saved
Share: