SQL ORDER By - two fields

lo5750ul

Senior member
Jul 18, 2001
744
0
76
I have a table with two columns of data (Data Type varchar and bit). I want to row sort the data by column two descending and then by column one ascending.

My SQL query thus far is:

SELECT *
FROM MyTable
ORDER BY column_two DESC, column_one


but the data is not sorted in column one.

I really need some help with this one.

Cheers.
 

Mitzi

Diamond Member
Aug 22, 2001
3,775
1
76
Bit confused as to what you want to do but I think you want to use a group by statement.

Try select * from table order by column_2 desc group by column_1

It doesn't work swap the order and group by statements around i.e.

select * from table group by column_1 order by column_2 desc


LMK if it works.
 

lo5750ul

Senior member
Jul 18, 2001
744
0
76
Mitzi,

Thank you for your help. GROUP BY would not work because the column_one Data Type is BIT. I cheated and changed it to Tinyint and my SQL then worked.