第一条:select amount_in from stocks_inout_jz where amount_in>0 and month_jz='2008年02月' 
第二条:select sum(amount_in) from stocks_inout_jz where month_jz='2008年02月'  我执行上面的语句,出现如下结果:
第一条语句是空语句,但是第二条语句返回的值却时:28823037615171174.40为何呀?

解决方案 »

  1.   

    select   amount_in   from   stocks_inout_jz   where   amount_in> 0 
    应该也没有数据,其实很简单就是没有条件满足!!!
      

  2.   

    amount_in   数据类型是什么?
      

  3.   

    檢查Amount_in是否有損壞的索引?
      

  4.   

    发表于:2008-02-11 07:48:341楼 得分:0 
    select       amount_in       from       stocks_inout_jz       where       amount_in>   0   
    应该也没有数据,其实很简单就是没有条件满足!!! 
     答:是没有懑足的条件,但是为何第二条语句却出现合计数据?
    发表于:2008-02-11 08:57:502楼 得分:0 
    amount_in       数据类型是什么? 
    答:amount_in是 NUMERIC(12,2)数据类型发表于:2008-02-11 09:52:373楼 得分:0 
    檢查Amount_in是否有損壞的索引? 答:我没有建立Amount_In的索引呀
      

  5.   

    第一条:
    where   amount_in> 0   and   month_jz='2008年02月'   
    第二条:
    where   month_jz='2008年02月'     条件不一样
      

  6.   

      amount_in数据类型是什么第二条:select   sum(amount_in)   from   stocks_inout_jz   where   month_jz='2008年02月'  
    改一下再查询一下  
    第二条:select   sum(amount_in)   from   stocks_inout_jz   where   amount_in> 0   and   month_jz='2008年02月'
      

  7.   


    第一条:select   amount_in   from   stocks_inout_jz   where   amount_in> 0   and   month_jz='2008年02月'   
    第二条:select   sum(amount_in)   from   stocks_inout_jz   where   month_jz='2008年02月'  两句的条件不一样啊第二条:select   sum(amount_in)   from   stocks_inout_jz   where   month_jz='2008年02月'  
    等价于select   amount_in   from   stocks_inout_jz   where   (amount_in<= 0 or amount_In is null)  and   month_jz='2008年02月'   
      

  8.   

    1、仔细检查 month_jz,amount_in的数据类型,和两个字段中值的问题;
    2、select    amount_in    from   stocks_inout_jz   where   month_jz='2008年02月'  order by   amount_in     desc 进行测试下
      

  9.   

    第一条:select   amount_in   from   stocks_inout_jz   where   amount_in> 0   and   month_jz='2008年02月'   
    第二条:select   sum(amount_in)   from   stocks_inout_jz   where   month_jz='2008年02月'    都改成
    select *
    检查一下输出数据就知道了。
      

  10.   

    是数据类型的问题,numeric(12,2)不够存放28823037615171174.40这样的大类型,会溢出的,你可以用numeric(38,2)替换
      

  11.   

    不是负值溢出!
    declare @t table(dd numeric(12,2))
    declare @i int
    set @i = 1
    while @i <10
    begin 
    insert @t select -9876543210.12
    set @i = @i +1
    end
    select sum(dd) sum from @t
    /*
    sum                                      
    ---------------------------------------- 
    -88888888891.08
    */
    declare @t table(dd numeric(38,2))
    declare @i int
    set @i = 1
    while @i <10
    begin 
    insert @t select -98765432109876543210987654321098765432.12
    set @i = @i +1
    end
    select sum(dd) sum from @t
    /*
    服务器: 消息 1007,级别 15,状态 1,行 6
    数字 '98765432109876543210987654321098765432.12' 超出了数字表示范围(最大精度为 38 位有效数字)。
    */
      

  12.   

    declare @t table(dd numeric(38,2))
    declare @i int
    set @i = 1
    while @i <10
    begin 
    insert @t select -987654321098765432109876543210987654.12
    set @i = @i +1
    end
    select * from @t
    select sum(dd) sum from @t 
    /*
    服务器: 消息 8115,级别 16,状态 2,行 10
    将 expression 转换为数据类型 numeric 时发生算术溢出错误。
    */
      

  13.   

    select amount_in from stocks_inout_jz where month_jz='2008年02月' order by amount_in 看看表里前面和后面的数据你就明白了的.