Forum

SQL Query to Displa...
 
Notifications
Clear all

SQL Query to Display Highest Amount Grater Than Rs 50000 Charged in the Resort.


Rahul Updhyay
Posts: 17
Topic starter
(@rahul)
Active Member
Joined: 11 months 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: 10 months 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: 10 months 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 totalpaid. 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: