0

我有以下查询来显示学生的每月费用状态。

SELECT regd, Name_of_Student, Class, Section, Rollno,
If(Month = 'January', Status, 0) AS Jan,
If(Month = 'September', Status, 0) AS Sept  
FROM fee
where Class='XI(Art)' and Rollno='2';

此代码的问题如图所示:

在此处输入图像描述

我想输出如下:

在此处输入图像描述

在实际应用中,我会显示所有月份。

请在此处查看小提琴

4

1 回答 1

3
SELECT regd, Name_of_Student, Class, Section, Rollno,
MAX(If(Month = 'January', Status, 0)) AS Jan,
MAX(If(Month = 'September', Status, 0)) AS Sept  
FROM fee
where Class='XI(Art)' and Rollno='2'
GROUP BY regd, Name_of_Student, Class, Section, Rollno;
于 2013-09-13T10:00:33.100 回答