I'm trying to get a subquery as a column with a condition.
The error I get from SQL Server is:
Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression.
There are a bunch more columns I'm selecting, but here is the main query that is giving ma an error:
SELECT ItemNo, Channel, Brand, TotalUnits,
(SELECT TotalUnits FROM Table1 WHERE Locked = 1) As LockedUnits
FROM Table1
EDIT: Locked is a 0 or 1 value
Ideally the query would return this (LockedUnits is always a subset of TotalUnits):
ItemNO Channel Brand TotalUnits LockedUnits
1 5 Adidas 100 80
2 7 Nike 500 360