日期:2014-05-19  浏览次数:20409 次

关于因为该列没有包含在聚合函数或 GROUP BY 子句中。
select   c.cnname,   CustName=a.chinaname   ,   title=a.title_c,  
  companyName=   a.company_c   ,   a.inputnum,a.FallNumList  
from   t_mate_regist   a,t_regist   b,t_base_nation   c    
where   a.nation=c.code   and   a.regid=b.regid   and   b.teamid   is   null
and   b.class=10   and   b.type=10   and   (a.chinaname= '许金诸 '   or   a.englishname= '许金诸 ')
group   by   a.company_c
having   count(*)> 1
order   by   company_c
========================
消息   8120,级别   16,状态   1,第   1   行
选择列表中的列   't_base_nation.CnName '   无效,因为该列没有包含在聚合函数或   GROUP   BY   子句中。
=======================


------解决方案--------------------
select c.cnname, CustName=a.chinaname , title=a.title_c,
companyName= a.company_c , a.inputnum,a.FallNumList
from t_mate_regist a,t_regist b,t_base_nation c
where a.nation=c.code and a.regid=b.regid and b.teamid is null
and b.class=10 and b.type=10 and (a.chinaname= '许金诸 ' or a.englishname= '许金诸 ')
group by a.company_c,c.cnname,a.chinaname,a.title_c,a.inputnum,a.FallNumList
having count(*)> 1
order by company_c

------解决方案--------------------
除company_c列外,其它输出列用聚合函数或也在group by 语句中,例如:
select max(c.cnname) as cnname,
CustName=max(a.chinaname),
title=max(a.title_c),
companyName= a.company_c ,
max(a.inputnum) as inputnum,
max(a.FallNumList) as FallNumList
from t_mate_regist a,t_regist b,t_base_nation c
where a.nation=c.code and a.regid=b.regid and b.teamid is null
and b.class=10 and b.type=10 and (a.chinaname= '许金诸 ' or a.englishname= '许金诸 ')
group by a.company_c
having count(*)> 1
order by company_c
------解决方案--------------------
select c.cnname, CustName=a.chinaname , title=a.title_c,
companyName= a.company_c , a.inputnum,a.FallNumList
from t_mate_regist a,t_regist b,t_base_nation c
where a.nation=c.code and a.regid=b.regid and b.teamid is null
and b.class=10 and b.type=10 and (a.chinaname= '许金诸 ' or a.englishname= '许金诸 ')
group by a.company_c,c.cnname,a.chinaname,a.title_c,a.inputnum,a.FallNumList
having count(*)> 1
order by company_c

------解决方案--------------------