|
kond.mohan
Posting Yak Master
India
138 Posts |
Posted - 05/30/2012 : 05:36:34
|
i am executing sql query in ssms 2008 based on type
empno, name, salary case when type=A then name end type1, case when type=D then name end type2, location
i got output like this
empno name sal type1 type2 date 1 dfl 100 ---- flsdf 19-08-2012 1 dfl 100 ---- dfggh 19-08-2012 1 dfl 100 k punct ------ 19-08-2012 1 dfl 100 k newyear ----- 19-08-2012
my expected out put is empno name sal type1 type2 date 1 dfl 100 k punct flsdf 19-08-2012 1 dfl 100 k newyear dfggh 19-08-2012
|
|
|
nigelrivett
Flowing Fount of Yak Knowledge
United Kingdom
3328 Posts |
Posted - 05/30/2012 : 07:29:36
|
No you don't. query has locatio, result has date - not possible. maybe select empno, name, salary max(case when type=A then name end) type1, max(case when type=D then name end) type2, location from tbl group by empno,name sal,location
========================================== Cursors are useful if you don't know sql. SSIS can be used in a similar way. Beer is not cold and it isn't fizzy. |
 |
|