I'm creating a custom SQL view in which we can find the quantities of items by location. At the moment it provides the information perfectly in columns, however can I provide this information with a subquery or aliasing to have that information in a row?
I've tried a select subquery, however it returns
Msg 512, Level 16, State 1, Line 1
Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression.
SELECT SKU, DESCRIPTION, QUANTITY, LOCATION
FROM INVENTORY
Output:
RB  RED BALL    0   OVERSTOCK
RB  RED BALL    1   ROOM 1
RB  RED BALL    3   ROOM 2
RB  RED BALL    5   ROOM 3
I would love to see:
SKU     DESCRIPTION    QTYOVERSTOCK QTYROOM1 QTYROOM2 QTYROOM3
--------------------------------------------------------------
RB      RED BALL            0           1       3        5
 
     
    