select top 1  * from table where xcode =1
union 
select top 1  * from table where xcode =2
union
select top 1  * from table where xcode =3

解决方案 »

  1.   

    这是你要实现的吗???
    select telNo,xcode,min(money) as money from table where xcode=1 union
    select telNo,xcode,max(money) as money from table where xcode=2 union
    select telNo,xcode,max(money) as money from table where xcode=3
      

  2.   

    更保险一点的:
    select top 1  * from table where xcode =1 order by telNo
    union 
    select top 1  * from table where xcode =2 order by telNo
    union
    select top 1  * from table where xcode =3 order by telNo^_^
      

  3.   

    如果xcode的值有多个呢?总不能用union写多个语句吧?我只关心xcode唯一,而telno与money则仅带着,其值大小及是否唯一并不重要
      

  4.   

    select * from yourtable as A 
     where telNo = (select min(telNo) from yourtable where xcode = A.xcode)
      

  5.   

    不知这个是否可以:
    select max(telno) as telNo,xcode,max(money) as money
    from table
    group by xcode
      

  6.   

    select top 1  * from table where xcode in(select distinct xcode form table)