views:

46

answers:

3

Hey all, this is my query string here:

 SELECT SUM(Total) as Total, AdministratorCode, SUM(WOD.Quantity) as thePass 
 FROM   tblWO as WO, 
        tblWOD as WOD
 WHERE WOD.OrderID = WO.ID 
 AND WO.OrderDate BETWEEN '2010-01-01' AND '2010-08-31' 
 AND Approved = '1' 
 ORDER BY WO.AdministratorCode

But i keep getting the error:

The multi-part identifier "tblWOD.Quantity" could not be bound.

Any help would be great!

Thanks,

David

SOLVED!!!

+2  A: 

You need to use SUM(WOD.Quantiy) (or maybe Quantity unless the column name is missing a t)

You have aliased the table here tblWOD as WOD so you have no table with the exposed correlation name tblWOD

Martin Smith
Ahhh a double whammy! Miss-spelled Quantity AND AS name! Thanks Martin! :o)
StealthRT
+2  A: 

In your Select clause, use just: SUM(Quantiy) rather than SUM(tblWOD.Quantiy). SUM(WOD.Quantiy) should also work

Patrick Karcher
+1  A: 

I believe you might need something like this

SELECT
    SUM(Total) as Total,
    WO.AdministratorCode,
    SUM(WOD.Quantity) as thePass
FROM tblWO as WO, tblWOD as WOD
WHERE
    WOD.OrderID = WO.ID
    AND WO.OrderDate BETWEEN '2010-01-01' AND '2010-08-31'
    AND [TableReference].Approved = '1'
Group By WO.AdministratorCode
ORDER BY WO.AdministratorCode
Sage
1. Out of curiosity, why would you answer a question that's already been successfully answered? 2. What is [TableReference]?
LittleBobbyTables
1) Maybe I didn't notice it had been answered. [TableReference] is because I don't know which of the 2 tables has the column Approved.
Sage