Click here to Skip to main content
15,889,808 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi, I hava a table like this.
ID   F01   F02   FO3
1    1     0     0
2    1     1     0
3    1     1     1

I Want the table reOrder like this
ID   F01   F02   FO3
3    1     1     1
2    1     1     0
1    1     0     0

Because the row 3, have 3, one in it's row.
row 2, have two, one in it's row.
and row1 have, the one , one in it's row.
Posted
Updated 17-Sep-14 22:10pm
v2

Hi,

You should be able to achieve your desired order by specifying multiple columns in the order by clause.

SQL
SELECT
 ID,F01,F02,F03
FROM
 tblData
ORDER BY
 ID DESC, 
 F01 DESC, 
 F02 DESC, 
 F03 DESC
 
Share this answer
 
Try this...
SQL
select * from tablename
Order by F01 desc, F02 desc, FO3 desc

Happy Coding! :)
 
Share this answer
 
Hi,

Check this...

SQL
SELECT * FROM your_Table order by 2 desc, 3 desc, 4 desc


i have not considered id as prime factor. Gave focus on values.


Also go through this..Order By[^]


Hope this will help you.

Cheers
 
Share this answer
 
v2
Comments
FarshadSh 19-Sep-14 11:24am    
i want the row3 become to row 1. becuse it have 3, one in it's row.
Magic Wonder 22-Sep-14 1:43am    
If you have this much of data in your table then use id for sorting in order by clause...like order by 1 desc, 2 desc, 3 desc, 4 desc....

In above query i assumed that your F01,F02,F03 should come w.r.t. values available in your data.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900