[Solved] Subquery returned more than 1 value. wrong if statement [closed]


You do not need any of these IF..ELSE statements or even the sub-queries in your select, what you are after, can be achieved with the following simple select query:

CREATE PROC GET_ORDER_ACCOUNT_DETAILS
 @ORDERID INT
AS 
BEGIN
 SET NOCOUNT ON;

    SELECT
          CASE 
               WHEN od.calcType="K"  
               THEN od.price * od.kilo 
               ELSE od.quant * od.price 
           END          as [AMOUNT]
         ,od.quant      as [QUANTITY] 
         ,od.kilo       as [KILO] 
         ,od.price      as [PRICE] 
         ,od.calcType   as [UNIT] 
         ,p.prodName    as [NAME] 
         ,od.recivedID  as [RECIVED]
    FROM       orderAccTBL     oa
    INNER JOIN orderDetailsTBL od ON od.orderID = oa.orderID
    INNER JOIN productTBL      p  ON p.prodID = od.productID
    WHERE oa.orderID = @ORDERID

END  

4

solved Subquery returned more than 1 value. wrong if statement [closed]