I am looking to create an order based on multiple columns in my table - all date related. For example: my columns are: fee_due
, fee_2_due
, fee_3_due
- they all contains results of various dates. However, I want to create an order combining all columns, so fee_due
might be 2012-11-03
, fee_2_due
might be 2012-11-01
and fee_3_due
might be 2012-11-02
.
My query needs to be:
SELECT *
FROM table_name
ORDER BY [date] DESC
... whereby the dates from the 3 columns join to form one order, regardless of what column they are in.
Hope that makes sense and thanks in advance.
Additionally you can:
SELECT *
FROM table_name
ORDER BY fee_due ASC,fee_2_due DESC,fee_3_due DESC
You can sort each column independently according to your need.
I used the following to make it work:
SELECT * FROM table ORDER BY camp1 ASC, camp2 ASC, camp3 DESC
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With