Does anybody know why my derived table completely ignores one particular where condition but accepts the rest?
SELECT A.`Part No`, A.`Selling Unit`, A.`Customer No`,
A.Description, A.`Bus Unit`, A.`Prod GP`, Format(`Cost Price`,
'Currency') AS `Cost Price`, Format(`Latest Price`, 'Currency')
AS `Latest Price`, A.`Prices Type`, A.`Product Manager`,
A.`Effective From Date`, A.`Creation Date`,
A.`Condition Type`
FROM tblPrice A INNER JOIN
(SELECT `Part No`, MAX(`Creation Date`)
AS `Creation Date`
FROM tblPrice
WHERE 1 = 1 AND
`Effective From Date` <= # 22 / 11 / 2005 # AND
`Prices Type` = 'International'
GROUP BY `Part No`) B ON A.`Part No` = B.`Part No` AND
A.`Creation Date` = B.`Creation Date`
ORDER BY A.`Part No` ASC
The "`Prices Type` = 'International'" returns records with other price types in but it filters on other fields OK (in this instance, it does filter on dates < = 21/11/05). The prices type field is a text field and if I do another SQL call on the tblPrice table without using the derived table and using "`Prices Type` = 'International'", that works fine.
Any help would be appreciated, am I missing something obvious here?
Thanks
Andrew
SELECT A.`Part No`, A.`Selling Unit`, A.`Customer No`,
A.Description, A.`Bus Unit`, A.`Prod GP`, Format(`Cost Price`,
'Currency') AS `Cost Price`, Format(`Latest Price`, 'Currency')
AS `Latest Price`, A.`Prices Type`, A.`Product Manager`,
A.`Effective From Date`, A.`Creation Date`,
A.`Condition Type`
FROM tblPrice A INNER JOIN
(SELECT `Part No`, MAX(`Creation Date`)
AS `Creation Date`
FROM tblPrice
WHERE 1 = 1 AND
`Effective From Date` <= # 22 / 11 / 2005 # AND
`Prices Type` = 'International'
GROUP BY `Part No`) B ON A.`Part No` = B.`Part No` AND
A.`Creation Date` = B.`Creation Date`
ORDER BY A.`Part No` ASC
The "`Prices Type` = 'International'" returns records with other price types in but it filters on other fields OK (in this instance, it does filter on dates < = 21/11/05). The prices type field is a text field and if I do another SQL call on the tblPrice table without using the derived table and using "`Prices Type` = 'International'", that works fine.
Any help would be appreciated, am I missing something obvious here?
Thanks
Andrew