/*
表里3条记录片段:
SORDER EDA BUN CUST NOUBA JITU0 APRICE
RR128254 0 1 CSZ003U CSZ004U 62.700 62.10000000
RR128254 0 2 CSZ003U CSZ004U 213.750 62.10000000
RR128254 0 3 CSZ003U CSZ004U 8.550 62.10000000
*/
select case when cust='chf001j'and nouba='chf001j' then ceiling(jitu0*aprice)
when right(cust,1)='j'and cust<>'chf001j'and nouba<>'chf001j'then round(jitu0*aprice,0)
else round(jitu0*aprice,2) end
from xract where sorder='RR128254'--照理应出来 round(jitu0*aprice,2)的结果,但是却出来ceiling(jitu0*aprice)的结果,怎么回事?
表里3条记录片段:
SORDER EDA BUN CUST NOUBA JITU0 APRICE
RR128254 0 1 CSZ003U CSZ004U 62.700 62.10000000
RR128254 0 2 CSZ003U CSZ004U 213.750 62.10000000
RR128254 0 3 CSZ003U CSZ004U 8.550 62.10000000
*/
select case when cust='chf001j'and nouba='chf001j' then ceiling(jitu0*aprice)
when right(cust,1)='j'and cust<>'chf001j'and nouba<>'chf001j'then round(jitu0*aprice,0)
else round(jitu0*aprice,2) end
from xract where sorder='RR128254'--照理应出来 round(jitu0*aprice,2)的结果,但是却出来ceiling(jitu0*aprice)的结果,怎么回事?
else 'c' end
from xract where sorder='RR128254'
出来应该是c
case when cust='chf001j'and nouba='chf001j' then 'a'
when right(cust,1)='j'and cust<>'chf001j'and nouba<>'chf001j'then 'b'
else 'c' end,
* from xract where sorder='RR128254'出来是c但用
select case when cust='chf001j'and nouba='chf001j' then ceiling(jitu0*aprice)
when right(cust,1)='j'and cust<>'chf001j'and nouba<>'chf001j'then round(jitu0*aprice,0)
else round(jitu0*aprice,2) end
from xract where sorder='RR128254'
出来就是
3894
13274
531
你试试:select case
when cust='chf001j'and nouba='chf001j' then cast(ceiling(jitu0*aprice) as numeric(10,2))
when right(cust,1)='j'and cust<>'chf001j'and nouba<>'chf001j'then cast(round(jitu0*aprice,0) as numeric(10,2))
else cast(round(jitu0*aprice,2) as numeric(10,2)) end
from xract where sorder='RR128254'
print ceiling(200)
/*
200.00
200
*/同样是打印ceiling(200),但第一种情况,它会根据CASE转成了非整型了