The following SQL code works fine if I don't use the CONVERT to make my column two characters wide. When using it as follows the error message reads:
"ORDER BY items must appear in the select list if SELECT DISTINCT is specified." If I just use:
SELECT DISTINCT MONTH(CTNoteDat e) it works fine.
How can I run this query with the column width set and sort the results?
Thanks! ~GregM
"ORDER BY items must appear in the select list if SELECT DISTINCT is specified." If I just use:
SELECT DISTINCT MONTH(CTNoteDat e) it works fine.
How can I run this query with the column width set and sort the results?
Code:
SELECT DISTINCT CONVERT(varchar(2),MONTH(CTNoteDate)) MO,
DATENAME(month,CTNoteDate) MONTH
FROM CTNotes WHERE YEAR(CTNoteDate)=2014
ORDER BY MONTH(CTNoteDate)
Comment