帮看一个SQL查询结果 - MS-SQL Server / 基础类
/*
表里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)的结果,怎么回事?
有点蹊跷,不知道啥原因。我在我机器上没问题,出来正确结果而来。
为了正确说明你得到的结果,将then 后都用字符串试试比如 then 'a' then 'b' else 'c'
你可以这样测试,就知道它读取的是哪个值
select 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
to 2楼,我试过了,用字符串得到的结果是对的,但一用正式的语句就不行了。见鬼。
select
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
相关问答:
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
org.apache.jas ......
从数据库中查询一张表的数据
select 部门,姓名 from tb
如何才能生成下面的xml格式
XML code:
<folder state="unchecked" label="全部">
<folder state="unchecked&qu ......
有这样一条SQL
Select Get_Costtaxrate(col1), Get_Tcostvalue(col1) from a
其中Get_Costtaxrate、Get_Tcostvalue都是函数,这两个函数里面都是查找一个大表,Get_Tcostvalue还需要调用Get_C ......
在Access的查询中执行下面的语句,无效,提示期待select ,updata ,...
CreateTble C=Answer N="回帖表"
(
C=ID T="INTEGER" P=No M=No N="编号" Z=false,
C=Ques ......