问题1:求sql语句
f1,f2.f3和f4表f1d1列232.8975
235.8973
267.8965
一共24条f2的d1列和f1的数据差不多
想向f4表传送数据,假如原来有数据就覆盖数据f4表
      f1    f2
01   232   需要保留1位小数
02   235
03   267
sql语句问题2:还有怎么把表f4只接受24行数据多余的忽略,不是不可以输入数据哦
各位大哥,是两个问题,别写成一个问题好不好,写多啦看不明白,谢谢

解决方案 »

  1.   

    还有怎么把表f4只接受24行数据多余的忽略
    select top 24?没看明白-_-
      

  2.   

    --4舍5入
    update f4 set f2=round(f1.d1列,1) from (select top 24 d1列 from f1) f1 where f4.f1=floor(f1.d1列)
    --不4舍5入
    update f4 set f2=(floor(f1.d1列*10)*1.0)/10 from (select top 24 d1列 from f1) f1 where f4.f1=floor(f1.d1列)
      

  3.   

    1.
    select id = identity(int,1,1), d1 into #tmp1 from f1
    select id = identity(int,1,1), d1 = round(d1,1) into #tmp2 from f2
    /*d1不四舍五入
    select id = identity(int,1,1), d1 = round(d1,1,1) into #tmp2 from f2
    */truncate table f4
    insert f4(f1,f2) select a.d1,b.d1 from #tmp1 a inner join #tmp2 b on a.id = b.iddrop table #tmp1,#tmp22.
    select id = identity(int,1,1), d1 into #tmp1 from f1
    select id = identity(int,1,1), d1 = round(d1,1) into #tmp2 from f2
    /*d1不四舍五入
    select id = identity(int,1,1), d1 = round(d1,1,1) into #tmp2 from f2
    */truncate table f4
    insert f4(f1,f2) select top 24     /*在此限制插入的行数为24行,其余行忽略*/
    a.d1,b.d1 from #tmp1 a inner join #tmp2 b on a.id = b.iddrop table #tmp1,#tmp2