Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

combine two columns into a single column Expand / Collapse
Author
Message
Posted Tuesday, February 15, 2011 12:03 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Friday, May 13, 2011 5:55 AM
Points: 9, Visits: 39
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
Post #1064038
Posted Tuesday, February 15, 2011 1:06 AM


SSC Eights!

SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!

Group: General Forum Members
Last Login: Monday, November 17, 2014 2:34 AM
Points: 882, Visits: 4,125
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
Post #1064056
Posted Tuesday, February 15, 2011 1:10 AM


Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Thursday, November 20, 2014 3:44 AM
Points: 1,260, Visits: 3,424
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/
Post #1064058
Posted Tuesday, February 15, 2011 4:57 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Friday, May 13, 2011 5:55 AM
Points: 9, Visits: 39
Thank q
Post #1064170
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse