0
我有一個表具有不同的列顯示不同的值。如何顯示1在其他列中的列總和
我需要添加一個新的列,顯示其他列的每一行中的1列的總和。
我已經寫了下面的查詢,但它只在最後一列的每一行顯示1
。
select inStation.name TapInStation , outStation.name TapOutStation,
count(trx.passengerCount) PassengerCount, sum(trx.amount) Fare,
(select sum(passengerCount) from transactions iTrx
where iTrx.ID = trx.ID) PassengerPercent
from transactions trx
inner join
station inStation on inStation.ID = trx.fromStation
inner join
station outStation on outStation.ID = trx.toStation
GROUP BY
TapInStation, TapOutStation
謝謝,它的工作..其實我需要把每行的百分比放在'最後一列',通過總和除以每行總數..但我沒有把第一件事情正確。 – Kirmani88