select * from table A where id=(select max(id) from table where A.id=id and id<>0)--------消除重复行数据,当ID=0的时候不算重复数据,现在我不想查询两遍获取数据,请问有什么好方法呢?

解决方案 »

  1.   

    select distinct 字段 from table A
    where id<>0
      

  2.   

    SELECT DSITINCT
        [ID],
        ******
    FROM
        [table]
    WHERE
        [ID] = 0
    UNION ALL
    SELECT
        [ID],
        ******
    FROM
        [table]
    WHERE
        [ID]>0
      

  3.   

    大哥我就是不想用 UNION ALL
    数据太长了写的很难看啊,请问有什么好方法呢?
    一条语句查出来
      

  4.   

    在请教一个问题,请问case when ...else  end 或者if..else 可以用在where之后吗?