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
 General SQL Server Forums
 New to SQL Server Programming
 Group by the result of LIKE

Author  Topic 

mukhan85
Starting Member

46 Posts

Posted - 2008-05-30 : 16:02:57
Hi, how are you? I have a table which contains the following columns:
SFINet SFICom SFUbit SFUroot
------ ------ ------ -------
1 ________ 2 ______3 _______4
is there any way to group by the first 3 letters:
SFI: 3 (sum of two columns: SFINet and SFICom)
SFU: 7 (sum of two columnts: SFUbit and SFUroot)

Thank you I appreciate your help!

jezemine
Master Smack Fu Yak Hacker

2886 Posts

Posted - 2008-05-30 : 16:29:09
like this?

select SFINet+SFICom, count(*)
from yourtable
group by SFINet+SFICom


elsasoft.org
Go to Top of Page

mukhan85
Starting Member

46 Posts

Posted - 2008-05-30 : 18:49:31
well, not exactly, the first two columns have SFI in common and the second two columns have SFU in common, so I need to Gropu by SFI and SFU and get the sum for each group. So I need to use somethink like where columnName LIKE "SFI%" ... and colName2 LIKE "SFU%"... something like that.
Thank you.
quote:
Originally posted by jezemine

like this?

select SFINet+SFICom, count(*)
from yourtable
group by SFINet+SFICom


elsasoft.org

Go to Top of Page

jezemine
Master Smack Fu Yak Hacker

2886 Posts

Posted - 2008-05-30 : 19:32:59
i still have no idea what you want.

post sample data and expected results based on that sample data.


elsasoft.org
Go to Top of Page
   

- Advertisement -