I'm trying to get an obsolete number value for two of my columns but because my case statement contains terminalid column I am required to group by terminal id which gives me multiple values.
Query:
SELECT
storenumber,
bbbtendertypetext,
CASE WHEN terminalnumber > 91 THEN
SUM( financialamounttendered ) - SUM( financialchangeamount )
END AS sco_net_value,
CASE WHEN terminalnumber < 91 THEN
SUM( financialamounttendered ) - SUM( financialchangeamount )
END AS front_end_net_value,
COUNT( transactionid ) AS transaction_count
FROM
AceTLogData.Tlog.tender
WHERE
transactiondatetime > '2022-09-21 00:00:00.000'
AND
transactiondatetime < '2022-09-22 00:03:00.000'
GROUP BY
storenumber,
terminalnumber,
bbbtendertypetext
ORDER BY
storenumber;
**Sample output **:
In the image you can see visa and gift card is coming in twice since they belong to two different terminals. So I am trying to see on how can I combine those duplicates in one so my SCO net sales, and transaction count would update as well.
