Navaz

Navaz

  • NA
  • 96
  • 45.1k

query

Jan 22 2014 6:02 AM
Else if EXISTS(select Supplier_Account_ID from Acc_Supplier acs
                    Left Join Salesman On Salesman_Id = Salesman.Salesman_ID
                    Where Transaction_Date = @TrDate And Salesman.Salesman_Name = @Salesman)
      
    Begin
        SELECT Acc_Supplier.Supplier_ID
            ,Acc_Supplier.Transaction_Date
            ,Acc_Supplier.Debit
            ,Acc_Supplier.Credit
            ,(select  Supplier.OB_Credit + ISNULL(sum(Acc_Supplier .Credit ),0)-(Supplier.OB_Debit  + ISNULL (sum(Acc_Supplier.Debit),0)) from Acc_Supplier
              where [Transaction_Date] < @TrDate And Supplier_ID = @SupplierId ) as PrevBalance
            ,(Select ISNULL(Sum(Debit),0)From Acc_Supplier Where Transaction_Date = @TrDate And Supplier_ID = @SupplierId) As Paid
            ,(Select Acc_Customer.[Debit]*Acc_Customer.[Commission]/100 from Acc_Customer  where [Transaction_Date]= @TrDate And Acc_Supplier.Supplier_ID = @SupplierId)  AS Commission
        FROM Acc_Supplier
        Left Join Acc_Supplier On Salesman.Salesman_ID = Acc_Supplier.Supplier_ID
        Left Join Supplier On Salesman.Salesman_ID = Supplier.Supplier_ID
        --Left Join Supplier On Supplier .Supplier_ID = Salesman_Name
        Where Acc_Supplier. Transaction_Date = @TrDate AND Acc_Supplier .Supplier_ID =@SupplierId
    end



error like Msg 1013, Level 16, State 1, Procedure sp_Sales_Report_Fishco , Line 79
The objects "Acc_Supplier" and "Acc_Supplier" in the FROM clause have the same exposed names. Use correlation names to distinguish them.

Answers (1)