unitario
unitario

Reputation: 6535

Microsoft Query: The Multi-Part Identifier Could Not be Bound

I am trying to write an query in Microsoft Query and it appears as there is some problem with the aliases but I cannot figure out how to fix it, any help would be highly appreciated!

SELECT   item."No_",
         item.Description,
         ItemLedgerEntry."Location Code",
         Sum(ItemLedgerEntry."Remaining Quantity") As Stock,
         Sum(bo."Outstanding Quantity") As BackOrder
FROM Nav50.dbo.item item, Nav50.dbo.ItemLedgerEntry ItemLedgerEntry
LEFT OUTER JOIN (   SELECT SalesLine.No_,
                    Customer.Name, SalesLine."Location Code",
                    SalesLine."Outstanding Quantity"
                    FROM Nav50.dbo.Customer Customer, Nav50.dbo.SalesLine SalesLine
                    WHERE SalesLine."Sell-to Customer No_" = Customer.No_) bo
ON ((item."No_" = bo.No_) AND (ItemLedgerEntry."Location Code" = bo."Location Code"))
WHERE item.No_ = ItemLedgerEntry."Item No_" AND ((ItemLedgerEntry."Location Code"='STHLM') AND (ItemLedgerEntry."Remaining Quantity"<>$0))
GROUP BY item."No_", item.Description, ItemLedgerEntry."Location Code"

The message I am getting is :

The Multi-Part Identifier "item.No_" could not be bound.

Upvotes: 1

Views: 891

Answers (1)

Taryn
Taryn

Reputation: 247690

instead of using double quotes try using square brackets:

SELECT   item.[No_]

full query that has been updated using JOIN syntax instead of commas between tables.

SELECT   item.[No_],
         item.Description,
         ItemLedgerEntry.[Location Code],
         Sum(ItemLedgerEntry.[Remaining Quantity]) As Stock,
         Sum(bo.[Outstanding Quantity]) As BackOrder
FROM Nav50.dbo.item item
LEFT JOIN Nav50.dbo.ItemLedgerEntry ItemLedgerEntry
    ON item.[No_] = ItemLedgerEntry.[Item No_] 
LEFT OUTER JOIN 
(   
    SELECT SalesLine.[No_],
           Customer.Name, 
           SalesLine.[Location Code],
           SalesLine.[Outstanding Quantity]
    FROM Nav50.dbo.Customer Customer
    LEFT JOIN Nav50.dbo.SalesLine SalesLine
        ON SalesLine.[Sell-to Customer No_] = Customer.[No_]
) bo
    ON ((item.[No_] = bo.[No_]) 
        AND (ItemLedgerEntry.[Location Code] = bo.[Location Code]))
WHERE ((ItemLedgerEntry.[Location Code]='STHLM') 
    AND (ItemLedgerEntry.[Remaining Quantity]<>$0))
GROUP BY item.[No_], item.Description, ItemLedgerEntry.[Location Code]

Upvotes: 1

Related Questions