Reputation: 77
I have a problem when selecting and grouping the following table. The table "Igralci" looks like this:
----------------------------------------------
|ID|U_ID|st_tock|st_srecanj|st_nizov|st_gemov|
----------------------------------------------
|19| 17 | 6 | 3 | 6 | 72 |
----------------------------------------------
|11| 19 | 12 | 6 | 24 | 144 |
----------------------------------------------
|15| 18 | 12 | 6 | 26 | 72 |
----------------------------------------------
I would like to sort the id's in the following way:
1. First looks at st_tock (if st_tock is same) ->
2. Looks at st_srecanj (if st_srecanj is same) ->
3. Looks at st_nizov (if st_nizov is same) ->
4. Looks at st_gemov
I tried:
Select * from Igralci
group by id, st_tock, st_srecanj, st_nizov, st_gemov
order by st_tock, st_srecanj, st_nizov, st_gemov;
The wanted display would be (ID's):
Upvotes: 0
Views: 61
Reputation: 924
You need to add "Desc" or "asc" to your order by clause to get the results you want. Based on the output you provided, you need to add "Desc" after each column in the order by
Select * from Igralci
group by id, st_tock, st_srecanj, st_nizov, st_gemov
order by st_tock desc, st_srecanj desc, st_nizov desc, st_gemov desc;
Upvotes: 1