Seat Type Quantity left
Business 23
Economy 27
First 15
Total quantity left : ?
DBMS = MySQL
I've tried the following SQL which to print the above information
$sql = "SELECT SeatType, COUNT(SeatType)AS quantity
FROM seat
WHERE SeatAvailable = 'Yes'
GROUP BY SeatType
";
How can i sum up the total quantity left(eg:23+27+25) ? Thx for the help in advanced...
SELECT COALESCE(SeatType, 'Total quantity left') `Seat Type`,
COUNT(SeatType)AS quantity
FROM seat
WHERE SeatAvailable = 'Yes'
GROUP BY SeatType WITH ROLLUP
Like this:
select sum(quantity_left) SeatsRemaining
from etc
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.