SQLTeam.com | Weblogs | Forums

Analytical function confusion


#1

Hi, I'm trying to figure out a solution to correctly sort a dataset and I think I've looked at it so long I can no longer see the forest or the trees. I thought I needed an analytic function to tell me which make had lowest percentage and then order that make and then sales pct. The first table contains a representative dataset and the second is my desired result:
Make      Model        SalesPct        Size
Ford       F150          .35                 1/2 Ton
Chevy    C1500        .32                 1/2 Ton
Ram      1500           .29                 1/2 Ton
Ford       F250          .33                 3/4 Ton
Chevy    C2500        .35                 3/4 Ton
Ram      2500           .32                 3/4 Ton
Ford       F350          .29                 1 Ton
Chevy    C3500        .34                 1 Ton
Ram      3500           .37                 1 Ton
This is what I would like (Ordered by Make that has lowest sale pct of 1/2 ton trucks but keeping make together):
Make      Model        SalesPct        Size
Ram      1500           .29                 1/2 Ton
Ram      2500           .32                 3/4 Ton
Ram      3500           .37                 1 Ton
Chevy    C1500        .32                 1/2 Ton
Chevy    C3500        .34                 1 Ton
Chevy    C2500        .35                 3/4 Ton
Ford       F350          .29                 1 Ton
Ford       F250          .33                 3/4 Ton
Ford       F150          .35                 1/2 Ton


#2

Look at ROW_NUMBER or possibly RANK

I thought this might work but now I am not so sure.