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 回答