select * from 表 where total>(select avg(total) from 表 where region=地区) and region=地区

解决方案 »

  1.   

    用average,具体格式忘了,建议参考一本数据库的书
      

  2.   

    谢谢哈,不过我的表里是同一个sales可以有几条记录的,麻烦大侠看清楚再回答哈
      

  3.   

    偶自己写出来了,谢谢大家啦~
    select c.orderid,c.total 
    from table c
    where not exists
    (select * 
    from (select region,avg(a.total) as regionavg  from table  a  group by region) b 
    where c.region = b.region and c.total < b.regionavg)可能还有更好的办法~
      

  4.   

    select a.corderid,a.total 
    from table a,
       (select region,avg(a.total) as regionavg  from table  a  group by region) b
    where
       a.region=b.region and a.total>b.regionavg