显示支付总费用 RS.50000 及以上的客人详细信息。编写查询以获取客人 ID、客人姓名和总费用总和
Display guest details who paid total charges RS.50000 and above. Write a query to fetch Guest id, Guest name and Sum of total charges
GUESTID NAME TOTALCHARGE
---------- ------------------------------ -----------
1234 RAJ GUPTA 30000
1235 JACK MARTIN 30000
1236 MARY GREY 32000
1234 RAJ GUPTA 30000
1235 JACK MARTIN 48000
这看起来像一个带过滤的聚合查询:
select guestid, name, sum(totalcharge) sum_totalcharge
from mytable
group by guestid, name
having sum(totalcharge) >= 50000
GUESTID NAME TOTALCHARGE
---------- ------------------------------ -----------
1234 RAJ GUPTA 30000
1235 JACK MARTIN 30000
1236 MARY GREY 32000
1234 RAJ GUPTA 30000
1235 JACK MARTIN 48000
这看起来像一个带过滤的聚合查询:
select guestid, name, sum(totalcharge) sum_totalcharge
from mytable
group by guestid, name
having sum(totalcharge) >= 50000