mysql 问题,找不到原因啊。
同一个SQL语句用Native Formysql查不出数据,用cmd命令却可以查的出,什么情况?
select Number as 学号,
sum(case `Subject` when '数学' then Sources end) as '数学',
sum(case `Subject` when '英语' then Sources end) as '英语',
sum(case `Subject` when '语文' then Sources end) as '语文',
sum(case `Subject` when '物理' then Sources END) as '物理',
sum(case `Subject` when '化学' then sources end) as '化学',
sum(case `Subject` when '生物' then sources end) as '生物',
sum(case `Subject` when '政治' then Sources end) as '政治',
sum(case `Subject` when '历史' then Sources end) as '历史',
sum(case `Subject` when '地理' then Sources end) as '地理',
SUM(Sources) as 总分, AVG(Sources) as 平均分
from test
group by Number;
表结构:
CREATE TABLE `test` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`Number` int(11) DEFAULT NULL,
`Subject` char(20) DEFAULT NULL,
`Sources` int(11) DEFAULT NULL,
PRIMARY KEY (`id`)
)