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.
| Author |
Topic |
|
bulubuk1976
Starting Member
24 Posts |
Posted - 2011-02-27 : 21:48:44
|
| Hi!I need help on how I can include % of count againts the total. Below is my sql statement. Don't know how:SELECT Count(UID), Level1 as Lvl1CountFROM dbo.View_table1 Group by Level1Count % Level 1 10 ? OThers21 ? aControllable 33 ? aUncontrollable 178 ? bControllable 9 ? bUncontrollable Thank you for the help. |
|
|
chris_n_osborne
Starting Member
34 Posts |
Posted - 2011-02-28 : 00:06:45
|
| Try dividing COUNT(UID) by COUNT(*), multiply by 100, and use CAST/CONVERT as necessary. |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2011-02-28 : 04:36:23
|
if you are using SQL 2005 / 2008count(UID) * 100.0 / sum(count(UID)) over() as [%] KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
|
|
|