开发者

Row convert to column in sql server 2005?

My table value is

    Esino  ym       workeddays  name
      1   200906        25        a 
      1   200907        24        a
      1   200908        27        a 
      2   200906         22       b
      2   200907        25....    b

I nedd out 开发者_开发技巧output is

     Esino   ym1     ym2    ym3      w1    w2   w3   name
      1      200906  200907 200908  25     24   27   a
      2      200906  200907  200908  22    25    21   b..

Condition is

  1. The ym is my input i given between month for dynamic for eg 200906 to 200912 or 200901 to 200906
  2. workeddays this also depend upon employee presents


You can use pivoting - have a look at this question, very close to your scenario.


you can do this sort of thing using PIVOT


Solution is Dynamic Pivoting. Have a look Problem in dynamic pivoting + sql server 2005

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜