原来的查询语句是:
select month_value,tot_value form fix_5900 where end_date>=2005/1/1 and end_date<=2005/4/1目的是:列出这段时间内的month_value 和tot_value值
现在新的要求:
month_value值是05年1月到4月的总值,而tot_value值要求是截止到2005年1月以前的值的总和
请问我个SQL语句怎么写????????????????????而且这结果要在同一个页面的表里显示

解决方案 »

  1.   

    两个条件都不一样,还是分成两句sql写吧
      

  2.   

    select (select month_value from fix_5900 where .....), (select tot_value from ......) from fix_5900;
    试一下怎么样
      

  3.   

    用UNION,求并集。
    SELECT * FROM fix_5900 where end_date>'2005/1/1' and end_date<'2005/4/1'  UNION SELECT * FROM fix_5900 where end_date <'2005/1/1';
      

  4.   


    i second that,you can try it 
      

  5.   

    UNION 查询两条记录,然后进行合并,但是会把重复的数据删除·
    UNION ALL 和上面不同的是,不会删除重复的数据,速度比UNION要快·~