UltraSmooth
Programmer
I have a query that totals up sales at retail and cost by Group/Location. Up to this point I have been just ordering my results by group name (alphabetically) and by location. I need to now sort by results by the Group with the most sales.
So if my results before were like the following,
CHILD
Loc1
Loc2
LAD
Loc1
Loc2
MEN
Loc1
Loc2
If the total MEN group did the most sales, followed by CHILD and then LAD the new order for my records would be
MEN
Loc1
Loc2
CHILD
Loc1
Loc2
LAD
Loc1
Loc2
I still need to see the individual locations records for the Group, but the Groups need to be sorted from highest to lowest based on total sales for that Group.
I've looked into ROLLUP which can calculate a total by GROUP but I don't see how I could sort all my records by this 'extra' row being inserted into my resultset.
Any help would be appreciated! I'd prefer to do this within the query itself rather than in the report.
So if my results before were like the following,
CHILD
Loc1
Loc2
LAD
Loc1
Loc2
MEN
Loc1
Loc2
If the total MEN group did the most sales, followed by CHILD and then LAD the new order for my records would be
MEN
Loc1
Loc2
CHILD
Loc1
Loc2
LAD
Loc1
Loc2
I still need to see the individual locations records for the Group, but the Groups need to be sorted from highest to lowest based on total sales for that Group.
I've looked into ROLLUP which can calculate a total by GROUP but I don't see how I could sort all my records by this 'extra' row being inserted into my resultset.
Any help would be appreciated! I'd prefer to do this within the query itself rather than in the report.