table name :TEST
ID NUM
1  3
1  4
2  5
3  6
7  9
3  8请问如何一个语句查询出同一ID有1个以上的NUM值

解决方案 »

  1.   

    select *
    from test 
    where id in (select id from TEST group by id having count(*)>1)
      

  2.   

    select id,count(distinct num) from test group by id
      

  3.   

    select id from test group by by having count(num)>1
      

  4.   

    select id from test group by id  having count(distinct num)>1
      

  5.   

    select *
    from test 
    where id in (select id from TEST group by id having count(*)>1)
    正解