Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 How to count percent in SQL?

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2004-09-24 : 08:41:29
Rose writes "Hi...
i want to count percent from this data:

I have one column name 'Kehadiran', so how can i count a percent, because i need to count total of that column and i need to count how many 'Y' in that same column.

please help me..

thanks."

jsmith8858
Dr. Cross Join

7423 Posts

Posted - 2004-09-24 : 08:52:06
hard to have any idea specifically what you are looking for, but in general:

select ID, 1.0 * Value / (Select SUM(Value) from tbl) as Pct
from tbl

will return each ID in a table, along with a value, and what that value is as a percentage as the total from the tbl.

- Jeff
Go to Top of Page
   

- Advertisement -