rivet Posted January 20, 2013 Share Posted January 20, 2013 I would like to order my results by name of month. If CHARINDEX was an option, this would be nice: ORDER BY CHARINDEX(LEFT(month_name, 3) , 'JAN', 'FEB', 'MAR', 'APR,' 'MAY', 'JUN', 'JUL', 'AUG', 'SEP', 'OCT', 'NOV', 'DEC') Here are my results for a google chart I am potting, I just need the proper order. ['Apr', 8], ['Aug', 7], ['Feb', 42], ['Jan', 30], ['Jul', 39], ['Jun', 26], ['Mar', 36], ['May', 31], ['Nov', 36], ['Oct', 17], ['Sep', 40] Link to comment Share on other sites More sharing options...
Claus Lavendt Posted January 20, 2013 Share Posted January 20, 2013 I am not aware that you can orderby with custom sorting, but you could use a custom function to sort the result after the sql query. E.g. this one: http://www.briandunning.com/cf/593 1 Link to comment Share on other sites More sharing options...
rivet Posted January 20, 2013 Author Share Posted January 20, 2013 Thanks Claus, processing the query with substitue did the trick, after I switch the query to return the month number instead of month name. 1 Link to comment Share on other sites More sharing options...
dansmith65 Posted January 20, 2013 Share Posted January 20, 2013 Thanks Claus, processing the query with substitue did the trick, after I switch the query to return the month number instead of month name. If the data you are selecting from contains both month name and number, can't you sort by month name, but select month number? Link to comment Share on other sites More sharing options...
Recommended Posts
This topic is 4134 days old. Please don't post here. Open a new topic instead.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now