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 |
immad
Posting Yak Master
230 Posts |
Posted - 2014-12-29 : 03:25:08
|
hi,my data is like this.---------code----------------nameACT706022774CCI0---------CCIACT706022774CCI0---------CCICDF892782322CCI4---------CCICDF892782322CCI4---------CCICDF892782322CCI4---------CCIi want a query that show data like this.---------code--------------------name---------ACT ----------------------2---------CDF-----------------------3i want to count ACT code and cdf codethanks for the help.immad uddin ahmed |
|
sunder.bugatha
Yak Posting Veteran
66 Posts |
Posted - 2014-12-29 : 04:13:46
|
/* select SUBSTRING(code,1,3) as Code ,COUNT(*) as Name from dbo.test1group by code */Hema Sunder |
|
|
MuralikrishnaVeera
Posting Yak Master
129 Posts |
Posted - 2014-12-29 : 04:22:56
|
select DISTINCT SUBSTRING(code,1,3) as Code,COUNT(*)over(PARTITION BY SUBSTRING(code,1,3)) as Name from dbo.#temp---------------Murali KrishnaYou live only once ..If you do it right once is enough....... |
|
|
|
|
|