这是我写的 codeselect distinct a.author_institution \
from author a \
full join co_author\
on a.author_id = co_author.author_id\
full join paper\
on paper.paper_id = co_author.paper_id\
where a.author_id in(select a1.author_id \
 from \
author a1 \
full join co_author\
on a1.author_id = co_author.author_id\
full join paper\
on paper.paper_id = co_author.paper_id\
where paper.paper_year = '2002' \
and paper.paper_conference LIKE 'SIGMOD' )\
group by a.author_institution ;")); 运行有错误但把 group by 去掉就好了 distinct 好像也不能用不知道为什么补充 group by 和distinct 可以对主码 但对其它项不行

解决方案 »

  1.   

    select distinct a.author_institution  
    from author a  
    full join co_author 
    on a.author_id = co_author.author_id 
    full join paper 
    on paper.paper_id = co_author.paper_id 
    where a.author_id in(
    select a1.author_id  
    from author a1  
    full join co_author 
    on a1.author_id = co_author.author_id 
    full join paper 
    on paper.paper_id = co_author.paper_id 
    where paper.paper_year = '2002'  
    and paper.paper_conference LIKE 'SIGMOD' ) 
      

  2.   

    or:select a.author_institution  
    from author a  
    full join co_author 
    on a.author_id = co_author.author_id 
    full join paper 
    on paper.paper_id = co_author.paper_id 
    where a.author_id in(
    select a1.author_id  
    from author a1  
    full join co_author 
    on a1.author_id = co_author.author_id 
    full join paper 
    on paper.paper_id = co_author.paper_id 
    where paper.paper_year = '2002'  
    and paper.paper_conference LIKE 'SIGMOD' ) 
    group by a.author_institution 
      

  3.   

    我主要的问题是 distinct 和 group by 的语句对 key 以外的项 就会出现错误不知道是不是我数据库的问题
      

  4.   

    有GROUP BY的查询 不需要DISTINCT 
      

  5.   

    我是 group by, distinct两个都不能用
      

  6.   

    group by, distinct不能同时出现。