IF EXISTS ( SELECT * FROM sysobjects WHERE xtype = 'fn' AND name = 'fn_NumberFormat' ) BEGIN DROP FUNCTION [dbo].[fn_NumberFormat] END GO CREATE FUNCTION [dbo].[fn_NumberFormat] ( @number MONEY , @points INT ) ) AS BEGIN --2015年3月17日11:29:36 --201501
#数字转字符保留几位小数 by gisoracle #数字转字符保留几位小数 by gisoracle def floattostr(num,xsnum): if xsnum==0: return str(int(num)) nd=round(num,xsnum) nstr=str(nd) idx=nstr.index('.') print idx p=len(nstr)-idx-1 print p n=xsnum-p print n s="" for i in range(n): s
用oracle sql对数字进行操作: 取上取整.向下取整.保留N位小数.四舍五入.数字格式化 取整(向下取整): select floor(5.534) from dual; select trunc(5.534) from dual; 上面两种用法都可以对数字5.534向下取整,结果为5. 如果要向上取整 ,得到结果为6,则应该用ceil select ceil(5.534) from dual; 四舍五入: SELECT round(5.534) FROM dual; ) FROM dua
换行的字符串 "This string\nhas two lines" 字符串中使用单引号时应该怎么写 'You\'re right, it can\'t be a quote' 把数字变成字符串并保留两位小数 var n = 123456.789 n.toFixed(0); //"123457" n.toFixed(2); //"123456.79" parseFloat(str)str以非数字开头,则返回NaN parseFloat(str)
1,下面是一个浮点类型的数字转成String字符串的例子 1 2 var f = 123.32342342 var s:String = "\(f)" //123.32342342 2,如果要保留两位小数 1 2 var f = 123.32342342 var s = String(format: "%.2f", f) //123.32
select num ,cast(round(convert(float,isnull((a.Sum_Num-d.Sum_Num),0))/convert(float,c.Sum_Store_Num)*100,1) as varchar(50))+'%' as 報告 from FORM 做除法运算,分母不为0,round函数保留一位小数.cast函数强制类型转换,转成字符串类型,然后与'%'进行字符串拼接. sql中换行符的使用: SQL本身并不使用换行符,因为换行符就跟空格符和回车符一样都