Results 1 to 3 of 3
  1. #1
    Join Date
    Mar 2004
    Posts
    33

    Unanswered: rows become columns help!

    I am building a calendar table for the most reason four weeks activitis and I have had a temp table data in table A (See my attached file) and I want to
    make it as the format in table B as final. How to convert it? Please help!

    Thank you!

    Suin
    Attached Files Attached Files
    • File Type: doc p.doc (83.0 KB, 67 views)

  2. #2
    Join Date
    Jan 2005
    Location
    Green Bay
    Posts
    201
    cut this and paste

    This should get you on your way.

    More formating needed

    select
    case when dow = 1 then vactype else null end MON,
    case when dow = 2 then vactype else null end TUES,
    case when dow = 3 then vactype else null end WED,
    case when dow = 4 then vactype else null end THUR,
    case when dow = 5 then vactype else null end FRI,
    case when dow = 6 then vactype else null end SAT,
    case when dow = 7 then vactype else null end SUN,
    nameitem,
    weeknum
    from(
    select 'VAC DAY' AS VACTYPE,
    'JOHN DOE' AS NAMEITEM,
    '1/1/2005' AS FULLWORK,
    datepart(dw,'1/1/2005') AS DOW,
    1 as weeknum
    union
    select 'VAC DAY' AS VACTYPE,
    'JOHN DOE' AS NAMEITEM,
    '1/2/2005' AS FULLWORK,
    datepart(dw,'1/2/2005') AS DOW,
    2 as weeknum
    union
    select 'VAC DAY' AS VACTYPE,
    'JOHN DOE' AS NAMEITEM,
    '1/3/2005' AS FULLWORK,
    datepart(dw,'1/3/2005') AS DOW,
    2 as weeknum
    union
    select null AS VACTYPE,
    'JOHN DOE' AS NAMEITEM,
    '1/4/2005' AS FULLWORK,
    datepart(dw,'1/4/2005') AS DOW,
    2 as weeknum
    union
    select null AS VACTYPE,
    'JOHN DOE' AS NAMEITEM,
    '1/5/2005' AS FULLWORK,
    datepart(dw,'1/5/2005') AS DOW,
    2 as weeknum) a

  3. #3
    Join Date
    Mar 2004
    Posts
    33

    thanks

    thanks thanks!
    Last edited by jqiu827; 12-06-05 at 17:07.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •