select case count(*) as c 
when c>0 then 'x' 
else 'y' end
from t_order 如果count()>1返回x,否则返回y,大致这么个意思,但这句sql是不正确的.

解决方案 »

  1.   

    select case when count(*)  
      >0 then 'x' 
    else 'y' end as c
    from sysobjects 
      

  2.   


    select case when count(*)  
      >0 then 'x' 
    else 'y' end as c 
    from sysobjects up
      

  3.   

    select case when flag>1 then 'X' else 'Y' from (select flag=count(*) from t_order)t
      

  4.   

    select case when count(*)>0 then 'x' 
    else 'y' end
    from t_order 
      

  5.   

    SELECT CASE WHEN C>0 THEN 'X' ELSE 'Y' END AS COL FROM 
    (
    select count(*) as c 
    from t_order )AS T
      

  6.   

    SELECT CASE WHEN C>0 THEN 'X' ELSE 'Y' END AS COL FROM 
    (
    select LTRIM(count(*)) as c 
    from t_order )AS T
      

  7.   

    select case count(*) when 0 then 'x' else 'y' end
    from tb select case when count(*)=0 then 'x' else 'y' end
    from tb 
      

  8.   

    select  case
             when count(*)>0 then 'x1' 
             when count(*)=0 then 'x2' 
             when count(*)<0 then 'x3' 
              else 'y' 
             end as c 
    from sysobjects CASE WHEN 实现多条件分支
      

  9.   

    select  case
             when count(1)>0 then 'x1' 
             when count(1)=0 then 'x2' 
             when count(1)<0 then 'x3' 
              else 'y' 
             end as c 
    from sysobjects