SELECT
(1.0*( SELECT SUM(r.SalesVolume)
FROM
RawData r
INNER JOIN Product p
ON r.ProductId = p.ProductId
WHERE p.Distributor in ('TF1','WARNER')
GROUP BY p.Distributor
)
/
( SELECT SUM(r.SalesVolume)
FROM RawData r
)*100)
;
The query above leads to an error:
Lookup Error - SQL Server Database Error: Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression.
Is the issue with the GROUP BY Clause? Not sure how to go about this.
Copyright Notice:Content Author:「Tauseef Hussain」,Reproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/31143589/sql-group-by-clause