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

Total Field and % of Total records in table

Status
Not open for further replies.

davebre

MIS
Jan 27, 2005
2
US
I need to create a field that totals the number of names and gives a persentage of the total records in the field?
Example

I have 5 records retrived with a quiry the table contains
apple plum, grape, orange.
The quirey returns the following from the record

apple
apple
plum
plum
plum

How do I get a total of 2 types returned the apple and plum and a persentage of the whole in the table of 5 entrys.

Thanks
David
 
A starting point:
SELECT yourField, 100*Count(*)/(SELECT Count(*) FROM yourTable) AS Percentage
FROM yourTable
GROUP BY yourField;

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top