Order by - testing on true/false

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • cezuk
    New Member
    • Feb 2007
    • 1

    Order by - testing on true/false

    Afternoon all

    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:

    Code:
    SELECT callId, callSubject, callNote, callBreachDate, callPriority
    FROM tblCall
    WHERE callCompleted = False
    ORDER BY callBreachDate
    This pulls all calls through in a nice order, showing the call with the least time left to be completed at the top.
    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!!!
Working...