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 Administration
 views problem

Author  Topic 

chriztoph
Posting Yak Master

184 Posts

Posted - 2009-12-06 : 21:50:26
Hi!
this is my table



and i have this view

SELECT     EmloyeeName, CASE WHEN signID = 2 THEN ApprovingOfficer END AS ApprovingOfficer1, CASE WHEN signID = 1 THEN ApprovingOfficer END AS ApprovingOfficer2
FROM dbo.ApprovingOfficer


what i want to happen make the output as 1 row only..

sample output:

[code]
EmloyeeName ApprovingOfficer2 ApprovingOfficer1
Christopher Librero Supervisor Manager
[code]

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2009-12-07 : 02:55:11
Try this
SELECT     
EmloyeeName,
max(CASE WHEN signID = 2 THEN ApprovingOfficer END) AS ApprovingOfficer1,
max(CASE WHEN signID = 1 THEN ApprovingOfficer END) AS ApprovingOfficer2
FROM
dbo.ApprovingOfficer
GROUP BY
EmloyeeName


Madhivanan

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

- Advertisement -