How to display multiple row values into single row

163 views Asked by At

Here my table is like this

Leave_Type Leave_Balance

CL              12
PL              10

Now i want to display my data like below

Leave_Type_CL Leave_Type_PL Leave_Balance_CL Leave_Balance_PL

CL      PL      12          10
1

There are 1 answers

0
Patrick On

Try this:

SELECT CONCAT(
   group_concat(CONVERT(Leave_Type, CHAR(2)) separator ' '),
   ' ',
   group_concat(CONVERT(Leave_Balance, CHAR(2)) separator ' ')
) FROM Leave_Table;