Hi guys, I have a simple question (I hope).

I need to order the results from an sql query by two colums. Now I have searched arround and found that you can use a comma in the order by table but it is not producing the desired results.

What I want to do is order overdue invoices first and then order the paid ones by date. My table looks like this:

id | date | overdue
1 | 12621137241 | 1

So what I am after is to list every invoice with overdue = 1 and then all the others in date order. Is this possible without multiple sql queires?

Thanks

s

    How is it not giving you desired results?

    If you use ORDER BY overdue DESC,date it should give you the results in desired order.

      7 days later

      You likely need a case statement in your order by, something like:

      order by 
          case when overdue then 1
              else 2
          end,
      otherfield
      
        Write a Reply...