Print largest number of records first

G

Garry

I have about 25k records, each record has a code ranging from 300 - 380

I would like to output the records with the greates number of codes first
down to the records with the least number of codes last

Code 300 has 400 records

Code 340 has 1000 records

Code 380 has 300 records etc

I would like to output Code 340,300,380 in that order

Is this possible with a query, Cheers
 
D

Douglas J Steele

One way would be to create a query that returns the number of records for
each code, join that query to your other table and use the count as an ORDER
BY.

Something like:

SELECT MyTable.Field1, MyTable.Field2, MyTable.Code
FROM MyTable INNER JOIN
(SELECT Code, Count(*) AS RecordCount
FROM MyTable
GROUP BY Code) AS CodeCount
ON MyTable.Code = CodeCount.Code
ORDER BY CodeCount.RecordCount, MyTable.Field1


"Garry" wrote in message
I have about 25k records, each record has a code ranging from 300 - 380

I would like to output the records with the greates number of codes first
down to the records with the least number of codes last

Code 300 has 400 records

Code 340 has 1000 records

Code 380 has 300 records etc

I would like to output Code 340,300,380 in that order

Is this possible with a query, Cheers
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top