0

I have an unsorted Table A.

C1    C2    C3      C4
----------------------    
15      2     7      5
12      5     4      8
19      1     3     12
21      9     1     18
 4     11    12     22

I want to sort this table in such a way that values with higher c1, higher c4, higher c2 and lower c3 are on top.

Also, c1 > c2 > c4 > c3 in terms of priority.

I am not sure how to go about this and would really appreciate any help from experts here.

Should I assign a fraction value to each column like c1 = .35 , c2 = .3, c4 = .2, and c3 = .15 and multiply the value for each column by its fraction value and add up all the values for each row?

6
  • I dont get it, what is your expected result after all? Commented Jul 14, 2015 at 13:30
  • 1
    What have you tried so far? Please have a look on "ORDER BY". This should be quite easy... Commented Jul 14, 2015 at 13:30
  • Like:21 9 1 18 19 1 3 12 12 5 4 8 15 2 7 5 4 11 12 22 Commented Jul 14, 2015 at 13:37
  • Don't get it. Please edit your question... Commented Jul 14, 2015 at 13:39
  • Why would 12 5 4 8 come before 15 2 7 5 ? Without a full explanation of the logic, no one can help you. Commented Jul 14, 2015 at 13:39

2 Answers 2

1

Sounds like you need:

ORDER BY C1 DESC, C2 DESC, C4 DESC, C3 ASC
Sign up to request clarification or add additional context in comments.

Comments

0

You mean simple order by? Then just add an order byclause:

ORDER BY C1 DESC, C4 DESC, C2 DESC, C3 ASC

DESC = descending, from highest to lowest .ASC = ascending, from lowest to highest

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.