我有一个 SQL 查询,该查询当前显示表HOTEL
中预订了 260 美元到 350 美元之间酒店的所有人员。我正在使用 ORACLE
SELECT guest.guest_name "GUEST NAME",
Count(guest.guest_no),
guest.guest_no "GUEST NUMBER",
room.r_price "ROOM PRICE"
FROM room,
guest,
booking
WHERE r_price >= 260
AND r_price <= 350
AND guest.guest_no = booking.guest_no
GROUP BY guest.guest_no,
guest.guest_name,
room.room_price
ORDER BY guest.guest_name;
我认为我可以仅按 GUEST.GUEST_NAME 进行分组(因此它将所有计数放在一个名称下,而不是将客人姓名加倍)。
编辑:查询的当前结果如下所示:
GUEST NAME COUNT GUEST_NO R_PRICE
Jenny Freeman 2 G003 260
Jenny Freeman 2 G003 295
Jenny Freeman 2 G003 310
Martin Ferguson 3 G006 260
Martin Ferguson 3 G006 295
Martin Ferguson 3 G006 310
Paul Happy 3 G002 260
Paul Happy 3 G002 295
Paul Happy 3 G002 310
Steve Kirkwood 3 G005 260
Steve Kirkwood 3 G005 295
Steve Kirkwood 3 G005 310
Tina Duncan 2 G001 260
Tina Duncan 2 G001 295
Tina Duncan 2 G001 310
Vanessa Horton 1 G007 260
Vanessa Horton 1 G007 295
Vanessa Horton 1 G007 310
但我期待这样的事情:
GUEST NAME COUNT GUEST_NO R_PRICE
Jenny Freeman 6 G003 260
Martin Ferguson 9 G006 310
Paul Happy 9 G002 310
Steve Kirkwood 9 G005 260
Tina Duncan 6 G001 310
Vanessa Horton 3 G007 260