Can anybody please tell me why I get the error Invalid column name 'Expr1' in the query text below?
Thanks very much,
Keyth
Code:
SELECT DeliveryNoteID, DelDate,
(SELECT COUNT(AutoID) AS Expr1
FROM Transport.dbo.DESPATCH_ITEM AS DI
WHERE (NOTE_NUMBER = DeliveryNotes.DeliveryNoteID) AND (Expr1 = 0)) AS cpc
FROM DeliveryNotes
WHERE (DelDate BETWEEN '20070101' AND '20080101')
ORDER BY DeliveryNoteID
Thanks very much,
Keyth