Select
AVG(Isc) as Isc, 
AVG(Uoc) as Uoc
from a
如:  
Isc Uoc
1 2
5 4
现在求的是Isc和Uoc的平均数,
然后我想在这个基础上再求,平均的Isc小于3大于0 并且  Uoc小于8 大于1的结果:
Isc Uoc
1 2问,怎么写?

解决方案 »

  1.   

    select * from (Select
    AVG(Isc) as Isc,  
    AVG(Uoc) as Uoc
    from a)twhere 
     isc>0 and isc<3
    and
     uoc<8 and uoc>1
      

  2.   

    Select
    AVG(Isc) as Isc,  
    AVG(Uoc) as Uoc
    from a
    having  AVG(Isc)>0 and AVG(Isc)<3 and AVG(Uoc)<8 and AVG(Uoc)>1
      

  3.   


    Select
    AVG(Isc) as Isc,  
    AVG(Uoc) as Uoc
    from a
    HAVING AVG(Isc) BETWEEN 0 AND 3 AND AVG(Uoc) BETWEEN 1 AND 8语句后面加上
      

  4.   

    我没说仔细,2楼你理解做错了,我想的是 先算出平均值,然后
    求:
    这个平均值在 0<平均值<3的平均值有哪些?  
      

  5.   

    select * from (Select
    AVG(Isc) as Isc,  
    AVG(Uoc) as Uoc
    from a)t
    group by Isc,uoc
    having  AVG(Isc)>0 and AVG(Isc)<3 and AVG(Uoc)<8 and AVG(Uoc)>1