目的是什么啊,获得所有来访的客人吧,
select * from table where n_cid in (select min(n_cid) from table group by s_cno)

解决方案 »

  1.   

    不必这样吧?select * from 表 a,(select s_CNo,min(id) as id from 表 group by s_CNo) as b
    where a.id=b.id
      

  2.   

    更正一下:select a.* from 表 a,(select s_CNo,min(id) as id from 表 group by s_CNo) as b
    where a.id=b.id或者:
    select a.* from 表 a
    where not exists (
    select * from 表 
    where s_CNo=a.s_CNo
    and id>a.id
    )