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)
 Like in Group by

Author  Topic 

xholax
Starting Member

12 Posts

Posted - 2010-11-17 : 10:44:00
Hello again, I hope you can help me , I tried to build query but I cant get it


I would like a query to sumarize , the following report



as you can see in the picture above, is something a : group by date field , shift field and part field with like but i cant get it.

Please I hope you can help me and sorry for my bad english.

jimf
Master Smack Fu Yak Hacker

2875 Posts

Posted - 2010-11-17 : 11:36:20
This solution only works if you always want the left 3 characters from the part column
select date,shift,left(part,3) as Part,sum([count]) as [count]
from yourTable
group by date,shift,left(part,3)


Jim

Everyday I learn something that somebody else already knew
Go to Top of Page

xholax
Starting Member

12 Posts

Posted - 2010-11-17 : 11:46:05
It also work with SUBSTRING
Go to Top of Page

jimf
Master Smack Fu Yak Hacker

2875 Posts

Posted - 2010-11-17 : 12:05:14
You're Welcome.

Jim

Everyday I learn something that somebody else already knew
Go to Top of Page
   

- Advertisement -