I'm trying to get my head around sub queries and I'm certain I don't actually know what I'm doing. I've got some code that pulls up the hotel names and room price, but the prices are showing the absolute total room price for all hotels together, not each hotel seperately.
SELECT hotelName, SUM(roomPrice) AS 'Room Price'
FROM hotel, room
GROUP BY hotelName
This code gives me this
2360 is the total room cost over every hotel, I just need to change it to show the cost of each hotels total rooms, individually.
EDIT: Added a image of the database relations
SELECT H.hotelName, SUM(R.roomPrice) as 'Room Price'
FROM hotel H
JOIN room R
ON H.hotelNo = R.hotelNo
GROUP BY H.hotelNo;
select SUM(b.roomPrice) AS 'Room Price' from hotel.hotel a, hotem.room b where a.hotelNo=b.hotelNo
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.