none
SQL QUERY - Only 3 characters needed to one column from another column

    Question

  • Hi,

    In my table (Reporting month) i have a one column with

    month details (November 2012, December 2012, September 2010,...) and

    another column semimonth with values(1,2) .

    Nov I need a new column in the same table with the details as

    "Nov - 1st semimonth" if the month is november 2012 and semimonth is "1" ,

    "Dec - 2nd semimonth" if the month is december 2012 and the semi month value is "2"...


    Wednesday, November 13, 2013 7:02 AM

Answers

  • I got the answer

    I need to use substring in case statement.

    case

    when semimonth = 1 then Substring(monthcolumnname, 1, 3) + '1st semimonth'

    when semimonth = 2 then Substring(monthcolumnname, 1, 3) + '2nd semimonth'

    Wednesday, November 13, 2013 7:29 AM