select * from t
order by (case when charindex('JB',VatNO)>0 then 1 else 0 end),standard desc

解决方案 »

  1.   

    select VatNO,standard from DyeProcessList
      order by case left(VatNO,2) when 'JB' then 1 else 0 end
      

  2.   

    select VatNO,standard from DyeProcessList
      order by case left(VatNO,2) when 'JB' then 1 else 0 end,standard desc若VatNO中间含有‘JB’的话charindex('JB',VatNO)>0就不行了
      

  3.   

    select VatNO,standard from DyeProcessListorder by  VatNO desc , standard desc
      

  4.   

    没仔细考虑   pbsql(风云)  的更好一些
      

  5.   

    在delphi里面怎么回报这样的错?? SQLText := ' select * from DyeProcessList a,DyeVat b where a.VatNo=b.VatNo  
                 order by case left(VatNO,2) when 'JB' then 1 else 0 end,standard descc '
    [Error] DyeDayPrn.pas(73): Missing operator or semicolon
    [Error] DyeDayPrn.pas(73): Statement expected, but expression of type 'String' found
    [Fatal Error] Salary.dpr(214): Could not compile used unit 'Report\DyeDayPrn.pas'
      

  6.   

    SQLText := ' select * from DyeProcessList a,DyeVat b where a.VatNo=b.VatNo order by case left(VatNO,2) when '''+JB+''' then 1 else 0 end,standard descc '-------中间不要回车,回车的话就用+连接
      

  7.   

    SQLText := ' select * from DyeProcessList a,DyeVat b where a.VatNo=b.VatNo order by case left(VatNO,2) when ''JB'' then 1 else 0 end,standard descc 'delphi中引号中的引号的使用规则与SQL SERVER一样的