Jump to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

SQL custom ORDER BY

Featured Replies

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]
 
 
 

 

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

  • Author

Thanks Claus, processing the query with substitue did the trick, after I switch the query to return the month number instead of month name.

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?

Create an account or sign in to comment

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.