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 2008 Forums
 Transact-SQL (2008)
 Grouping values of a column

Author  Topic 

mrm23
Posting Yak Master

198 Posts

Posted - 2010-07-21 : 05:19:13
Hi All,

I have a scenario like this:

the user can create his own object from available templates.

But here there can be hundreds of objects with the same name or which begin with the same name.
for example , my table has one and half lakh rows.

the data is somewhat like:
createhouse
addcurtain
.
.
.
but the data will actually be like if you make
select * from table having name like create% you will get 100-150 rows.
they all begin with create but they are diff. like createhouse, createpool etc....

now we need to group these data for our report purpose. we are thinking to group all these create% stuffs as one gp, add% stuff as second group and so on...

can we write query for this?

slimt_slimt
Aged Yak Warrior

746 Posts

Posted - 2010-07-21 : 05:32:09
please post some sample data. and what is your desired output.
Go to Top of Page

mrm23
Posting Yak Master

198 Posts

Posted - 2010-07-21 : 05:48:12
My data is like this:

addlotsize 30x
addlotsize 32x
addlotsize 35
addlotsize 40
addlotsize 40x
addlotsize 42
addlotsize 50
ADDTRAIT
Addtrait
addtrait
addtrait 'bookw
addtrait 'brave
addtrait 'great
addtrait 'green
addtrait 'hope
addtrait 'hopel
addtrait 'insa
addtrait 'loves
addtrait 'natu

Now i must get data like:

addlotsize
addtrait


I.e i have tried to figure out what types are available, ignoring how many times they are repeating.
so my one and half lakh will come down to 180-200 rows.
Go to Top of Page
   

- Advertisement -