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

stored procedure

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
Hello,

would you please help me how to get percentage breakdown from field?

example:

I have the table named "complaints".How to write stored procedure to get percentage berakdown of complaints by Category(taxis, moving companies, towing companies, others)??

Thank you very much for your kind help.
 
[tt]declare @nTotalRecs int
select @nTotalRecs = count(*) from Complaints

select Category,
count(Category)*100/@nTotalRecs as Percentage
from Complaints
group by Category [/tt]

I haven't tested this, but I think its close. Robert Bradley
Sr. DBA, some big company
cheap prints and oil paintings:
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top