I have the following simple query.
select max(CalendarDate) from
(select top 6 (CalendarDate) from Calendar
where CalendarYear = datepart(yyyy,getdate())
and datepart(mm,CalendarDate) = datepart(mm,getdate())
and CalendarCode = 'usa'
and CalendarDayType = 'T'
The max value in the table is 2010-09-30 00:00:00.000
But according to the subset condition when i run it separately the value is 2010-09-09 00:00:00.000
When i add the max in the select statement as stated above i get 2010-09-30
instead of 2010-09-09
What am i doing wrong here?
View Complete Post