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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sorting in Crosstab Queries

Status
Not open for further replies.

titanl

Technical User
Apr 13, 2009
23
SC
Hi,

Is there a way to sort records in crosstab queries? I try but it says:

"Cannot have aggregate function in ORDER BY clause"

Any suggestion?

Thanks.
 
Pls find below the SQL view of the crosstab.
I want to sort by the [Total of Points] column

Code:
TRANSFORM Sum([qryRankingAndMedalStandings_BestPrimary_Boys/Girls].Points) AS SumOfPoints
SELECT [qryRankingAndMedalStandings_BestPrimary_Boys/Girls].SchoolName, Sum([qryRankingAndMedalStandings_BestPrimary_Boys/Girls].Gold) AS SumOfGold, Sum([qryRankingAndMedalStandings_BestPrimary_Boys/Girls].Silver) AS SumOfSilver, Sum([qryRankingAndMedalStandings_BestPrimary_Boys/Girls].Bronze) AS SumOfBronze, Sum([qryRankingAndMedalStandings_BestPrimary_Boys/Girls].Points) AS [Total Of Points]
FROM [qryRankingAndMedalStandings_BestPrimary_Boys/Girls]
GROUP BY [qryRankingAndMedalStandings_BestPrimary_Boys/Girls].SchoolName
PIVOT [qryRankingAndMedalStandings_BestPrimary_Boys/Girls].SchoolNo;

Thanks.
 
As you have discovered, you can't sort on a non-group by row heading in the crosstab. You can create a new query based on the crosstab and sort in it:
Code:
SELECT * 
FROM qxtbYourCrosstabName
ORDER BY [Total Of Points];

Duane
Hook'D on Access
MS Access MVP
 
Actually this is what did yesterday, but I was just hoping that there could be a way around it.

Thanks again for the time and suggestion, dhookom. You've been of very good help.

titanl
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top