[thelist] CF & SQL: Selecting unique months from date column
rudy
rudy937 at rogers.com
Thu Jul 17 19:12:24 CDT 2003
> > SELECT Month(DateColumn), Year(DateColumn)
> > FROM TableName
> > GROUP BY Year(DateColumn), Month(DateColumn)
>
> > (the order of the GROUP BY clause is important)
>
> Tab,
>
> Why is the ordering in the GROUP BY clause important in this query?
short answer: it isn't
long answer: because all other things being equal -- i know, i know,
sometimes they aren't -- the GROUP BY sequence of columns is the sort order
the groups will be returned in
saves an explicit ORDER BY
occasionally this can make a big difference in performance of large queries
rudy
More information about the thelist
mailing list