Display Column as Rows

There is a table T with two columns C1 and C2.
The data is as below:
C1 C2
1 4
2 5
3 6
display the result as :
1 2 3
4 5 6

Showing Answers 1 - 9 of 9 Answers

Manjeera

  • Nov 30th, 2016
 

SELECT [1],[2],[3]
FROM [dbo].manj
PIVOT
(
sum( orders)
FOR number IN ([1],[2],[3])
) AS P

  Was this answer useful?  Yes

vikas bose

  • Nov 3rd, 2017
 

In MySQL, we have one function GROUP_CONCAT(field_value, separator). It will give single row.
SELECT GROUP_CONCATE(field_Value, ,) FROM table_name where 1 group by field_name.

  Was this answer useful?  Yes

Santhosh Kumar Gujja

  • Nov 27th, 2017
 

sel max(case when rn=1 then c1 end),max(case when rn=2 then c1 end),max(CASE WHEN RN=3 THEN c1 end)
union all
sel max(case when rn=1 then c2 end),max(case when rn=2 then c2 end),max(CASE WHEN RN=3 THEN c2 end)2
(
SEL c1,c2,row_number() over(order by C1) as rn
)O

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions