Site Sponsored By: SQLDSC - SQL Server Desired State Configuration
Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
I have a date table that has month and year that I can retrieve. I want to order by month and date combination for the report.I want Oct-03,nov-03,... followed by Jan-04I am formatting it as follows..SELECT avg(cast(t1.R1 as money)) r, (left(td1.monthdesc,3)+'-'+ + right(td1.year,2)) Monthyear, sum(t1.rc) NumberOfR FROM t1 INNER JOIN td1 ON.............but I cannot order by the MonthYear field as it is ordering in alphbetical order.Any ideas?
ehorn
Master Smack Fu Yak Hacker
1632 Posts
Posted - 2004-03-05 : 16:52:16
HOW about the following order by statement:
ORDER BY convert(datetime,'01-' + (left(td1.monthdesc,3) + '-' + right(td1.year,2)),103) ASC
jsmith8858
Dr. Cross Join
7423 Posts
Posted - 2004-03-06 : 10:32:23
WHY must people store dates as text !!!!????Argghh !!store it as a date type, and you can format and sort on it anyway you like ...- Jeff