0
studentid inst_n0 1st_pay              2nd_pay           3rd_pay 4th_pay
50       4     22/02/2011|25000|Y 08/04/2011|17500|Y|5  22/01/2012|25000|N|27   22/04/2012|17500|N|26   

私はそれをこのようにしたい:-

studentid inst_no       payment              pay_n0
50         4       22/02/2011|25000|Y        1st_pay 
50         4       08/04/2011|17500|Y        2nd_pay
50         4       22/01/2012|25000|N        3rd_pay
50         4       22/04/2012|17500|N        4th_pay

私を助けてください...

4

1 に答える 1

-1
select studentid, inst_no, 1st_pay as 'payment', '1st_pay' as 'pay_n0' from tableName

union

select studentid, inst_no, 2st_pay as 'payment', '2st_pay' as 'pay_n0' from tableName

union

select studentid, inst_no, 3st_pay as 'payment', '3st_pay' as 'pay_n0' from tableName

union

select studentid, inst_no, 4st_pay as 'payment', '4st_pay' as 'pay_n0' from tableName
于 2012-11-08T05:43:02.707 に答える