Sort by size of groups (1 Viewer)

SnowPatrol

Registered User.
Local time
Today, 04:17
Joined
Feb 18, 2006
Messages
17
Hi, as ever, am sure this is simple...

I have a field in a table which is a code. This code is used to allocate records to certain groups. I want to run a query which then returns the records, grouped by code and displayed in ORDER of the biggest group. So if there are 20 records with Code A and 15 with Code B and 67 with Code C the Code C records should come first, then B, then A.

Can anyone help???

Thanks!

A
 

KenHigg

Registered User
Local time
Today, 07:17
Joined
Jun 9, 2004
Messages
13,327
I'm thinking you need to do a seperate totals query and then include / link this query back into the original query with the totals count column used to sort on...

Hope that kinda of made sense...???
 

SnowPatrol

Registered User.
Local time
Today, 04:17
Joined
Feb 18, 2006
Messages
17
Hi Ken, thanks for your reply. Sorry for being dumb but....! I did as you suggested. The initial query sorts the recods into their groups of allocation groups but I cannot work out how to order them in the way I want in a subquery. Do I need to use Count in an expression? This just seems to return rubbish??!!
Sorry...I have just been banging my head against the same wall for 6 hours!
 

KenHigg

Registered User
Local time
Today, 07:17
Joined
Jun 9, 2004
Messages
13,327
When you do the totals query one of the options is to count the occurances of the value...
 

SnowPatrol

Registered User.
Local time
Today, 04:17
Joined
Feb 18, 2006
Messages
17
Thanks Ken- I was approaching it in the wrong (and frankly ludicrous way!) After a nights sleep (and wine) I see what you mean.

Cheers!
 

Users who are viewing this thread

Top Bottom