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
 Link between two table

Author  Topic 

derrick_goi
Starting Member

6 Posts

Posted - 2011-11-29 : 01:16:37


how should i do if i want the result come out with :

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-11-29 : 03:09:35
hmm...sorry we cant see what result you're expecting

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2011-11-29 : 05:44:39
You need PIVOT. Refer this post
http://beyondrelational.com/blogs/madhivanan/archive/2008/08/27/dynamic-pivot-in-sql-server-2005.aspx

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

sureshkk
Starting Member

21 Posts

Posted - 2011-11-29 : 08:31:53
SELECT shiftid,[Cimpack System]+[FloorTrack System] [count],
[Cimpack System] cimpack,
[FloorTrack System] floortrack
FROM
(
SELECT * FROM #test
) p
PIVOT
(
SUM(job) FOR [system] in([Cimpack System],[FloorTrack System])
) a
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-11-29 : 11:10:39
seeing data i think what you need is fuzzy grouping rather than normal group by as values are not exactly the same

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -