Reputation: 1079
SELECT
((1.0 * (SELECT SUM(r.SalesVolume)
FROM RawData r
INNER JOIN Product p ON r.ProductId = p.ProductId
WHERE p.Distributor = 'TF1', 'WARNER')
GROUP BY p.Distributor)
/
(SELECT SUM(r.SalesVolume) FROM RawData r)*100)
;
The above query gives an error:
Lookup Error - SQL Server Database Error: Incorrect syntax near ','.
Could anyone point out what the issue is? I know for a fact that I cant use OR/AND condition in this case. The result set has to have 2 rows.
Product:
Distributor
WARNER
TF1
WARNER
TF1
RawData:
SalesVolume
5
6
3
4
Upvotes: 3
Views: 113
Reputation: 3620
perhaps IN
instead of =
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'))
/
(SELECT SUM(r.SalesVolume) FROM RawData r)*100)
;
Upvotes: 2