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 |
|
csphard
Posting Yak Master
113 Posts |
Posted - 2005-05-30 : 02:44:04
|
| I need to get percentages. I was going to get my counts using a group by and calculate my percentages. Can sql do this for me and if so how |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2005-05-30 : 02:58:10
|
| declare @t table(no int, s char(5))insert into @t values(1,'Test')insert into @t values(1,'Test')insert into @t values(2,'Test')insert into @t values(2,'Test')insert into @t values(2,'Test')insert into @t values(3,'Test')insert into @t values(3,'Test')insert into @t values(4,'Test')Select no,c, c*100.0/(select count(*) from @t) percentage from(select no, count(*)as c from @t group by no) TMadhivananFailing to plan is Planning to fail |
 |
|
|
csphard
Posting Yak Master
113 Posts |
Posted - 2005-05-30 : 04:23:55
|
| For my understanding. Create a temporary table. Question my information and insert it.Get my percentages. I am looking at @t (SELECT @local_variable)This is new to me |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2005-05-30 : 04:40:42
|
| @t is the table variable.Move your result of your group by query to temporary table use the query based on that tableMadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|