select * from 职工表 a where 工资<(select avg(工资) from 职工表 where 仓库号=a.仓库号)

解决方案 »

  1.   

    create table t1(a varchar,b int)insert t1
    select '1',122
    union all select '2',123
    union all select '1',142
    union all select '2',312select * from t1 aa where b<(select avg(b) from t1 where a=aa.a)drop table t1a         b
    -----------
    1 122
    2 123
      

  2.   

    select a,b,c
    from table
    where c<(select avg(c) from table)
      

  3.   

    上述是SQL SERVER的写法,VFP不知道是否适用
      

  4.   

    --如果你的工资是整型,建议改用:select * from 职工表 a 
    where 工资<(select avg(cast(工资 as float)) from 职工表 where 仓库号=a.仓库号)
      

  5.   

    select 职工号from 职工表 where 工资<(
    select 平均工资=avg(工资) from 职工表 where 仓库号=本仓库号) and  仓库号=本仓库号
      

  6.   

    select a.* from 职工表 a inner join (select 仓库号,avg(工资) 平均工资 from 职工表 group by 仓库号) b on a.仓库号=b.仓库号 where a.工资<b.平均工资