Results 1 to 3 of 3
  1. #1
    Join Date
    Oct 2004
    Location
    In cousin's house
    Posts
    303

    Unanswered: Case in SqlServer

    Hi,
    I have a table and field below.

    Payroll table
    Id Period Net_pay
    001 010105 5000
    001 011605 300
    001 030105 1000
    001 040105 150
    002 010105 1000
    002 011505 500


    I want the display like this if posible.. The first to character of the field period is the Month January to December.
    Id January February March April ..............
    001 5300 00 1000 150 .............
    002 1500 00 00 00 .................


    Thank...

  2. #2
    Join Date
    Jun 2003
    Location
    Ohio
    Posts
    12,592
    Provided Answers: 1
    You want a CROSSTAB query. Look it up in Books Online and you will get as good an explanation of how to do this as you could get on this forum.

    Your only challenge should be converting the numeric string date format to the MonthName columns you want. You will need to do a CONVERT, CAST, or some other function, depending upon whether you have to worry about spanning years or not.
    If it's not practically useful, then it's practically useless.

    blindman
    www.chess.com: "sqlblindman"
    www.LobsterShot.blogspot.com

  3. #3
    Join Date
    Oct 2004
    Location
    In cousin's house
    Posts
    303
    Thanks Mr. Blindman for the reply...

Posting Permissions

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