I'm trying to write a query thats orders data in a specific way, depending on specific rows in the database...
Basically, the application pulls data from a Customer Management database, and displays a list of 'outstanding calls' relevant to what group you're in. Currently, its set to order all calls by the amount of time left to complete the work before the call 'breaches' (ie, passes the time set out in our service standards). HOWEVER, Ive now been asked to ensure that all priority 1 calls are listed first, regardless of any other outstanding calls.
So, for arguements sake, lets say the query is this:
Expand|Select|Wrap|Line Numbers
- SELECT callId, callSubject, callNote, callBreachDate, callPriority
- FROM tblCall
- WHERE callCompleted = False
- ORDER BY callBreachDate
Ideally - all within a single SQL query (if possible) - I'd like to:
1st: order by priority 1 calls first (ie, WHERE callPriority = 1)
2nd: order whats left by callBreachDate
However, simply sorting by callPriority won't work, as theres some special calls that are logged as priority 0, so 1 isnt the 'lowest number' (so to speak).
Any help with this would be much appreciated. If any further clarification is needed, let me know!!!