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 |
|
mrm23
Posting Yak Master
198 Posts |
Posted - 2010-10-19 : 05:28:08
|
| Hi All,I have a table with a million rows.There is an object_name column which has data like:object_nameMicrosoft SQL Server 2000Microsoft SQL Server 2005Microsoft SQL Server 2000Microsoft SQL Server 2008Microsoft SQL Server 2008Microsoft SQL Server 2005....1 million rowsNow, I need to make 3 groups out of these million records as2000||2005||2008a || b || ca,b,c being the data related to them.How can i make this? Currently we have a query for this which uses CASE statement.But in the real scenario, we have 96 such groups!!!!!So writing 96 Case statements has slowed down the query badly and i need to tune this now.Is there a better approach for this?Thanks in adv. |
|
|
michael.appleton
Posting Yak Master
160 Posts |
Posted - 2010-10-19 : 05:58:18
|
| First you have to decide what makes them a group. In the example you gave, the last four characters define each group. Then just use the group syntax in SQL to make them groups in each row rather than columns. You can format or transpose the data to columns as groups afterwards in the front end. |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2010-10-19 : 13:24:44
|
| will number of groups be known before? or will it vary at runtime?------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
|
|
|