declare @i as numeric(18,2)
set @i=78.00
print @i
print cast(@i as int)

解决方案 »

  1.   

    看错了,呵呵
    首先,你的字段设置小数位设置的太多,否则不会出现这么多0,
    再有,你的需求好象在客户端设置显示格式更好些.
    比如客户端用vb时,可以用format()函数对数据显示进行格式化.
      

  2.   

    首先谢谢楼上的;
    其次再说说我的问题:我字段设置小数位是1,直接SELECT显示是一位小数
    但那个语句里(得分=round(score/times,1) )是一个两个字段相除的一个算法,结果就给“得分”这个字段了,我用round函数四舍五入了,所以成了那个样子,能有什么好办法么,多谢了!
    附:我有C#,.net2003开发,想把上面那个表直接绑到DataGrid 上
      

  3.   


    select 员工号=staff_code,姓名=staff_name,得分=cast(round(score/times,1) as numeric10,1)) 
    from yw_graded  where score != 0 and times !=0
      

  4.   

    少了个括号
    cast(round(score/times,1) as numeric(10,1))
      

  5.   

    如果就想保留一位就好办了,不过比如是23.0的话,不会显示成23
    比较一下下面的输出吧.
    select round(6.2/5,1)
    select cast(round(6.2/5,2) as numeric(10,1))
      

  6.   

    select round(6.2/5,1)
    select cast(round(6.2/5,1) as numeric(5,1))
    --------
    --------- 
     1.200000 (所影响的行数为 1 行)        
    ------- 
        1.2 (所影响的行数为 1 行)