how can I convert rows of my table as column value for eg I have a table a
emp id 1 2 3 4
and I want my output as
1 2 3 4
i am also using pivot in oracle and crosstab in postgres but not able to get desired solution as shown above.
how can I convert rows of my table as column value for eg I have a table a
emp id 1 2 3 4
and I want my output as
1 2 3 4
i am also using pivot in oracle and crosstab in postgres but not able to get desired solution as shown above.
Check the listagg function. Note you need at least Oracle 11 for this.
Use this script and change it to your values to get desired results
SELECT * FROM (SELECT emp_id, emp_points
FROM emp_data)
PIVOT (
SUM(emp_points) AS sum_emp_points
FOR (emp_id) IN (1 AS [1], 2 AS [2],3 AS [3],4 AS [4])
);
select * from (select empno from t7) pivot(min(empno) for empno in (1,2,3,4));