select ROUND(num*price,2) as totalprice from book

解决方案 »

  1.   

    用mid(number,第几位起,取几位):
    x=123456
    y=mid(x,2,3)
    結果:y=234
      

  2.   

    呵呵,什么叫广本型?
    用formatnumber看看吧,用法和format几乎一样的
      

  3.   

    to lihonggen0(用VB) 
    执行后说round函数未定义
      

  4.   

    to mickwang(Mick)
    是文本形
    执行后也是说formatnumber函数未定义是不是这个函数不支持用在SQL语句里啊?
      

  5.   

    select ROUND(num*price,2) as totalprice from book在Sql Server里ROUND()函数没问题
      

  6.   

    sql server中
    select cast(num*price as numeric(18,2)) as totalprice from book
      

  7.   

    to lihonggen0(用VB) 
    我在ACCESS里执行就没错。
    可是在程序里用CONN.execute("select ROUND(num*price,2) as totalprice from book"
    )就是函数未定义
    我是用ADO
    是不是我那里弄错了?
      

  8.   

    select ROUND(num*price,2) as totalprice from book
    后面都是零!
    有效位数不变
      

  9.   

    to ferrytang(ferry)
    你的方法在access里都不行!
    请问在ACCESS里应该怎么做??急啊!
      

  10.   

    跟你说一下!
    num是数字[册数]
    price 是货币[单价]
    rebate 是数字[折扣]我想求每一本书的实洋
    结果这样算出来,小数有很多位。
    这样所有记录求和后就有0.01到0.05的差别,可财务说不行。
      

  11.   

    说round函数未定义 应该在5.0中
    如果在6.0中一般是可以的
      

  12.   

    这个可能对你有点用
    http://www.csdn.net/expert/topic/533/533226.xml?temp=.9201929
    主  题:  怎样四舍五入? 
    'MainNumber是要转化的数,Number要保留的位数
    Private Function CRound(MainNumber As Double, Number As Double) As Double
        CRound = Int(MainNumber * 10 ^ Number + 0.5) / 10 ^ Number
    End FunctionPrivate Sub Command1_Click()
        Print CRound(-3.145, 2) '3.15
    End Sub
      

  13.   

    to:xxlroad(土八路)
    谢谢您。不过现在是如何才能在执行SQL语句时就已经把结果保留两位数!
      

  14.   

    在access中用format语句格式化select format(num*price,'0.00') as totalprice from book
    在sql 中
    select convert(numeric(20,2),num*price) as totalprice from book
      

  15.   

    to mazhayang(蚂蚱先生) 
    用FORMAT函数可以,但是在报表里对TOTALPRICE这个字段求和却不行了,说丢失数据类型!