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 2005 Forums
 Transact-SQL (2005)
 Frequency Counts From Huge Table

Author  Topic 

GhantaBro
Posting Yak Master

215 Posts

Posted - 2008-03-12 : 23:57:03
Hey guys,

I have a table with about 80 columns and 400 millions records. Each columns has different responses that I need to get frequency for. I need to get counts for each response from all the columns... I have a query that does it, but it will run forever... what is the best way to do so?

My starting query:

select res, sum(cnt) from
(
select col1 res, count(*) as cnt from table1 with (nolock)
group by col1
union all
select col2 res, count(*) as cnt from table1 with (nolock)
group by col2

........................

select col80 res, count(*) as cnt from table1 with (nolock)
group by col80
)a group by res

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-03-13 : 12:50:04
Whats the requirement for doing this?
Go to Top of Page
   

- Advertisement -