--1.
select * from your_table a
where (select count(1) from your_table where Province = a.Province and Pname = a.Pname)>1
order by address

解决方案 »

  1.   

    --2
    select top 200 * 
    from your_table a
    where exists(select 1 from your_table where Pname = a.Pname and tel = a.tel and PID <> a.PID)
    order by PID
      

  2.   

    --3
    declare my_cursor for select * from your_table where Province = '广东' and city = '广州'
    open my_cursor
    fetch next from my_cursor
    while(@@fetchstatus = 0)
    begin
        print '100'
    end
    close my_cursor
    deallocate my_cursor
      

  3.   

    1[code=SQL]   
    select * from your_table where Pname not in(seielt not distance(Pname ) where your_table) and Province='北京'[/ code]大概是这样写的  没在SQL中实验
      

  4.   

      order by address  忘记加了
      

  5.   

     1、select * from tb a
    where (select count(1) from tb where Pname = a.Pname)>1 and Province='北京'
    order by address
     2、select top 200 * from tb a where (seleect count(1) from tb where a.Pname=Pname and a.Tel=Tel)>1
     3、declare cursor my_cursor for select * from tb where Province = '广东' and city = '广州'
    open my_cursor
    fetch next from my_cursor
    while(@@fetchstatus = 0)
    begin
      ......
    end
    close my_cursor
    deallocate my_cursor
      

  6.   

    --假设表名为t
    --1.
    select * from t a where province='北京' 
    and exists(select * from t where province='北京' and pid<>a.pid and pname=a.pname) 
    order by [address]
    --2.
    select top 200 * from t a where 
     exists(select * from t where pname=a.pname and tel=a.tel and pid<>a.pid) 
    --3.
    d
    declare t_cur cursor for select * from t where province='广东' and city='广州'
    open t_cur
    fetch next from t_cur
    while @@fetch_status=0
    begin
    fetch next from t_cur
    end