I am using the TSQL select statement:
SELECT RATE_TABLE_ID,"PROJECT" = RATE_KEY_VALUE1,"CODE" = RATE_KEY_VALUE2, "EFFECT_DATE" = MAX(EFFECT_DATE),RATE,"CODE_VALUE_DESC" = ISNULL(PJCODE.CODE_VALUE_DESC,""FROM PJRATE
LEFT OUTER JOIN PJCODE ON PJCODE.CODE_TYPE = "0CDE" AND PJCODE.CODE_VALUE = LTRIM(RTRIM(RATE_KEY_VALUE2))
WHERE RATE_TABLE_ID = "INV" GROUP BY RATE_TABLE_ID,RATE_KEY_VALUE1,RATE_KEY_VALUE2,RATE,CODE_VALUE_DESC,RATE_TYPE_CD
the table I am querying has rates with efective dating. Therefore I am only interested in the rate with the most recent date. This query retrieves one record for each rate, therefore the max function is not working. The data type for effective_date is smalldatetime.
Is the mssql7.0.
There is a bug with mssql 7.0 with this function? If, why doesn't this query just return one record, the one with the most recent date.
SELECT RATE_TABLE_ID,"PROJECT" = RATE_KEY_VALUE1,"CODE" = RATE_KEY_VALUE2, "EFFECT_DATE" = MAX(EFFECT_DATE),RATE,"CODE_VALUE_DESC" = ISNULL(PJCODE.CODE_VALUE_DESC,""FROM PJRATE
LEFT OUTER JOIN PJCODE ON PJCODE.CODE_TYPE = "0CDE" AND PJCODE.CODE_VALUE = LTRIM(RTRIM(RATE_KEY_VALUE2))
WHERE RATE_TABLE_ID = "INV" GROUP BY RATE_TABLE_ID,RATE_KEY_VALUE1,RATE_KEY_VALUE2,RATE,CODE_VALUE_DESC,RATE_TYPE_CD
the table I am querying has rates with efective dating. Therefore I am only interested in the rate with the most recent date. This query retrieves one record for each rate, therefore the max function is not working. The data type for effective_date is smalldatetime.
Is the mssql7.0.
There is a bug with mssql 7.0 with this function? If, why doesn't this query just return one record, the one with the most recent date.