我在SQL里表里面定义了一张表,如下
create table dsc_pr
(序号 int identity(1,1),
分子 float,
分母 float,
分子/分母 as 员数)
但是员数的类型也为float, 我怎么能员数的类型固定为decimal(7,3)呢?也就是不得超过3位小数呢?
高手们,期待着你们的解答……

解决方案 »

  1.   

    create table dsc_pr
    (序号 int identity(1,1),
    分子 float,
    分母 float,
    分子/分母 as 员数)
    但是员数的类型也为float, 我怎么能员数的类型固定为decimal(7,3)呢?也就是不得超过3位小数呢?
    -----------------
    select 序号,分子,分母,cast(分子/分母 as decimal(7,3)) as 员数 from dsc_pr
      

  2.   

    首先谢谢楼上的超级大帅哥啊……
    不过我不非要SELECT语句显示,我要在数据库表里就显示不得超过3位小数~
    再帮我费心一下哈……
      

  3.   

    create table dsc_pr
    (序号 int identity(1,1),
    分子 float,
    分母 float,
    员数 as  cast(分子/分母 as  decimal(8,3)))insert into dsc_pr
    select 2.0,1.0