[thelist] CF & SQL: Selecting unique months from date column

rudy rudy937 at rogers.com
Wed Jul 16 17:24:43 CDT 2003

> DISTINCT Month(your_date_field) AS themonth
> FROM your_calendar_table
> ORDER BY your_date_field

some databases will not let you sort a result set on a field that isn't in
the result set

when you use DISTINCT you automatically force a sort anyway, so you can just
omit the ORDER BY

however, DISTINCT often gets people into trouble (not that it doesn't work,
it's just that people do not fully understand how it works), so i recommend
the GROUP BY solution that Tab submitted


More information about the thelist mailing list