Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations MikeeOK on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Re-grouping

Status
Not open for further replies.

Trevor11

Programmer
Nov 22, 2004
5
CA
I have a table that contains the following data.

Group A priority_points
001001924 421715
001001924 0
001001924 125
001014182 0
001014182 625
001015924 0
001015924 14
001015924 160
001021690 0
001021690 562
001050152 15870
001050152 58858
001050152 18954
001147495 131
001147495 250
001147495 30
001200443 0
001200443 0
001200443 83005

I would like to re-group the table so that priority points column is sorted in descending order whilst keeping the Group A column grouped together. So that it looks like this.

Group B priority_points
001001924 421715
001001924 125
001001924 0
001200443 83005
001200443 0
001200443 0
001050152 58858
001050152 18954
001050152 15870
001014182 625
001014182 0
001021690 562
001021690 0
001147495 250
001147495 131
001147495 30
001015924 160
001015924 14
001015924 0

Thanks for any help
 
SELECT [Group A], priority_points
FROM yourTable
ORDER BY 1, 2 DESC

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Thanks,

That sorts it so that the Priority scores are sorted descending within each group. However what I need is the the highest Priority score to be listed in descending order but then to keep all assoiciated group numbers wiht that particular group number listed underneath. As in the example above. Group number 001200443 has moved from the bottom of list to second in the list because the priority score is 2nd highest for a group.

Hope i've explained that properly.
 
you need a third column: group

so you'd get
sort first by group, second by points.
Group Priority Points
groupA 19394384 494

Mark P.
Providing Low Cost Powerful Point of Sale Solutions.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top