Chinaunix首页 | 论坛 | 博客
  • 博客访问: 676727
  • 博文数量: 118
  • 博客积分: 2933
  • 博客等级: 少校
  • 技术积分: 1779
  • 用 户 组: 普通用户
  • 注册时间: 2010-07-27 10:16
文章存档

2013年(35)

2012年(27)

2011年(23)

2010年(33)

分类: 系统运维

2012-12-04 13:52:12

原句:
select count(1) totalCount from (select o.courseCode, o.name ,
(select count(a.id)  from apply_learn a where a.type=1 and a.courseId=o.id) ,
(select count(b.id)  from apply_learn b where b.type=1 and b.status=3 and b.courseId=o.id) ,
o.updateTime  from o_course o where o.status=12) tmp_count_t
这样老提示说找不到对应的3,4列名无效
 
经过最后的解决:
  一定要加上别名,要不hibernate不认识。
select count(1) totalCount from (select o.courseCode, o.name ,
(select count(a.id)  from apply_learn a where a.type=1 and a.courseId=o.id) AS totstr,
(select count(b.id)  from apply_learn b where b.type=1 and b.status=3 and b.courseId=o.id) as totstr1,
o.updateTime  from o_course o where o.status=12) tmp_count_t
阅读(1853) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~