数据库db中有个字段为SD_QD是浮点型,我想把大于0和小于0的  个数  放在dbgrid的两个列中还有一列是他们的和 
求一条sql语句 
并且按时间排序  
   时间      大于0   小于0 
   0-2       这个时间的个数
   2-4
    。
    。
    。   22-24 

解决方案 »

  1.   

    select sum(select * from tableA where SD_QD > 0),sum(select * from tableA where SD_QD < 0) from tableA
      

  2.   

    这条sql语句不对啊麻烦你调试看一下
      

  3.   

    select
     '0-2' as "时间",
     sum(select SD_QD from tableA where SD_QD > 0 and time between 0 and 2) as "大于0",
     sum(select SD_QD from tableA where SD_QD < 0 and time between 0 and 2) as "小于0"
    from tableA
    until all
    select 
     '2-4' as "时间",
     sum(select SD_QD from tableA where SD_QD > 0 and time between 2 and 4) as "大于0",
     sum(select SD_QD from tableA where SD_QD < 0 and time between 2 and 4) as "小于0"
    from tableA可能语句会过不去,你自己看着改改,基本语法基本给你写好了。
    没人有时间帮你调试,你如果一点手都不动,是什么也学不到的