问题描述
select count(advicedeta0_.topic_id) as col_0_0_, base_data2_.column_name as col_1_0_, advicedeta0_1_.congressId as col_2_0_ from advice_detail advicedeta0_ inner join topic advicedeta0_1_ on advicedeta0_.topic_id=advicedeta0_1_.id, Congress congress1_, Base_data base_data2_ where advicedeta0_1_.congressId=congress1_.id and congress1_.title=base_data2_.id and advicedeta0_1_.Congress_govid=2 and advicedeta0_1_.topictype=1 group by advicedeta0_1_.congressId order by base_data2_.id 问题补充:chen_yongkai 写道
解决方案
order by 的字段需要出现在select中,所以也有在group by 字句中
解决方案二:
不是聚合函数的字段,都要group by,就是除了你的count,sum这些聚合函数生成的字段外,都要列入group by分组中,此外,oracle中group by的字段不能是你起的别名,其他的数据库好像可以是别名,此外,你order by的字段并没有出现在select中被选择出,这样就找不到这个字段
解决方案三:
刚才说错了应该错在group by 字句少了base_data2_.column_nameselect count(advicedeta0_.topic_id) as col_0_0_, base_data2_.column_name as col_1_0_, advicedeta0_1_.congressId as col_2_0_ from advice_detail advicedeta0_ inner join topic advicedeta0_1_ on advicedeta0_.topic_id=advicedeta0_1_.id, Congress congress1_, Base_data base_data2_ where advicedeta0_1_.congressId=congress1_.id and congress1_.title=base_data2_.id and advicedeta0_1_.Congress_govid=2 and advicedeta0_1_.topictype=1 group by advicedeta0_1_.congressId,base_data2_.column_name order by base_data2_.id
解决方案四:
是topic吧mysql没有