combine two columns into a single column

  • select month_value, year_value, answer from transaction

    the output is like as

    -----------------------

    month_value year_value answer

    ____________________________

    7 2010 54

    8 2010 89

    9 2010 76

    10 2010 67

    1 2011 34

    2 2011 43

    i want output like

    datewise answer

    ____________________

    7/2010 54

    8/2010 89

    9/2010 76

    10/2010 67

    1/2011 34

    2/2011 43

  • if you mon and year is int then :-

    select convert(varchar(20),monvalue)+'/'+ convert(varchar(20),year) as datewise, ans from yourtable

    And if mon and year are varchar then :-

    select monvalue +'/'+ year as datewise, ans from yourtable

    ----------
    Ashish

  • I don't know your data type in your table, and one of the options can be:

    SELECT CAST(month_value AS NVARCHAR) + '/' + CAST(year_value AS NVARCHAR) AS YOUR_FIELD FROM TRANSACTION

    ============================================================
    SELECT YOUR PROBLEM FROM SSC.com WHERE PROBLEM DESCRIPTION =
    http://www.sqlservercentral.com/articles/Best+Practices/61537/[/url]

  • Thank q

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply