Seat Type Quantity left
Business 23
Economy 27
First 15
Total quantity left : ?
DBMS = MySQL
我已经尝试了以下用于打印上述信息的SQL
$sql = "SELECT SeatType, COUNT(SeatType)AS quantity
FROM seat
WHERE SeatAvailable = 'Yes'
GROUP BY SeatType
";
我如何总结剩余的总量(例如:23 + 27 + 25)? 感谢先进的帮助...
答案 0 :(得分:1)
SELECT COALESCE(SeatType, 'Total quantity left') `Seat Type`,
COUNT(SeatType)AS quantity
FROM seat
WHERE SeatAvailable = 'Yes'
GROUP BY SeatType WITH ROLLUP
答案 1 :(得分:0)
像这样:
select sum(quantity_left) SeatsRemaining
from etc