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
select a,b,c from table where c<(select avg(c) from table)
上述是SQL SERVER的写法,VFP不知道是否适用
--如果你的工资是整型,建议改用:select * from 职工表 a where 工资<(select avg(cast(工资 as float)) from 职工表 where 仓库号=a.仓库号)
select 职工号from 职工表 where 工资<( select 平均工资=avg(工资) from 职工表 where 仓库号=本仓库号) and 仓库号=本仓库号
select a.* from 职工表 a inner join (select 仓库号,avg(工资) 平均工资 from 职工表 group by 仓库号) b on a.仓库号=b.仓库号 where a.工资<b.平均工资
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
from table
where c<(select avg(c) from table)
where 工资<(select avg(cast(工资 as float)) from 职工表 where 仓库号=a.仓库号)
select 平均工资=avg(工资) from 职工表 where 仓库号=本仓库号) and 仓库号=本仓库号