sql中保留小数

CUPOFWORD 2011-06-22 11:34:16
SELECT t1.sbvid AS DJID,
t1.ccuscode as KHDM,
t1.csbvcode AS XSDH,
t3.cinvcode AS SPDM,
t3.cinvname AS SPMC,
t3.cinvstd AS SPXH,
t4.cComUnitName AS SPDW,
t2.iquantity AS SPSL,
SPDJ=case
when t1.ccuscode=170034 then str(cast(t2.iunitprice as varchar(20)),charindex('.',cast(t2.iunitprice as varchar(20)))+4,4)
else t2.iunitprice
end,
t2.iunitprice,round(t2.iunitprice,4),
t2.imoney AS SPJE,
t2.itaxrate/100 AS SL,
t2.itax AS SE,
SPDJHS=case
when t1.ccuscode=170034 then str(cast(t2.itaxunitprice as varchar(20)),charindex('.',cast(t2.itaxunitprice as varchar(20)))+4,4)
else
t2.itaxunitprice
end,
t2.isum AS SPJEHS,
(100000+t2.autoid) AS MXXH
FROM salebillvouch t1 LEFT JOIN salebillvouchs t2 ON t1.sbvid=t2.sbvid
LEFT JOIN inventory t3 ON t2.cinvcode=t3.cinvcode
LEFT JOIN ComputationUnit t4 ON t3.cComunitCode=t4.cComunitCode


这是我写的sql语句 但是测试的时候 总是得不到自己想要的数据
t2.itaxunitprice 得到的还是原始数字
我想让这个字段保留四位小数
注:我的这个要保留的字段类型是float型的

求赐教!!!
...全文
63 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
zs621 2011-06-22
  • 打赏
  • 举报
回复

CAST(t2.itaxunitprice AS DECIMAL(18,4))
这样吗?
-晴天 2011-06-22
  • 打赏
  • 举报
回复
convert(decimal(18,4),t2.itaxunitprice)
AcHerat 2011-06-22
  • 打赏
  • 举报
回复

convert(decimal(18,4),t2.itaxunitprice) as itaxunitprice
--小F-- 2011-06-22
  • 打赏
  • 举报
回复
cast(t2.itaxunitprice as decimal(18,4)) as itaxunitprice

22,209

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server 疑难问题
社区管理员
  • 疑难问题社区
  • 尘觉
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧