Quantcast
Channel: Forum Getting started with SQL Server
Viewing all articles
Browse latest Browse all 4729

nested sql sorting

$
0
0
I have three fields as below:

f1    f2    f3
b    x    100.22
c    y    150.15
a    x    240.35
a    y    130.25
b    y    789.34
c    x    199.89

I want to sort them like this:

f1    f2    f3
b    y    789.34
b    x    100.22
a    x    240.35
a    y    130.25
c    x    199.89
c    y    150.15

The main sort should be done based on f3, so the group of f1 values that have bigger sum value in f3 should be upper (descending order).
Also the values of f3 should be ordered descending in their own group.





Viewing all articles
Browse latest Browse all 4729


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>