简体   繁体   中英

SQL Query - finding multiple sums with a row

I need some help trying to find out how I can make this SQL Query try and find the total sums for all unique BatchNo's

something like this:

|BatchNo| Sum |
    1     20
    2     45
    3     22

this is what i have right now.

SELECT BatchNo,
SUM(raw_bat_sum.STOTS + raw_bat_sum.STOTR)
AS Sum
FROM raw_bat_sum
WHERE raw_bat_sum.BatchNo= ?;
SELECT BatchNo,
(SUM(raw_bat_sum.STOTS) + SUM(raw_bat_sum.STOTR))
AS Sum
FROM raw_bat_sum
GROUP BY raw_bat_sum.BatchNo;

EXAMPLE HERE

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM