Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 23857

Order by one column, but keep related columns together

$
0
0

I have a view with a number of columns. For simplicity, lets say there are the following columns:

SiteID, FeatureID, HighestScore, AverageScore

So there is a site, with a number of features. Each feature has a score. The view shows these scores, and then calculates the highest score and the average score.

What I need to do is order the data according to the HighestScore, and then the AverageScore. However, the problem is that each site can appear more than once in this data. I need to keep the Sites together.

For example, I can easily get the following:

SiteIDFeatureIDHighestScoreAverageScore
1A144
2B144
1A233
3C133

But I actually need SiteID 1 to stay together, ie:

SiteIDFeatureIDHighestScoreAverageScore
1A144
1A233
2B144
3C133

The data could easily be thousands or rows.


Viewing all articles
Browse latest Browse all 23857

Trending Articles



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