求教VFP分组统计
在VFP中怎么通过SQL语句或编程实现如下统计结果?
表中含字段:工号,姓名,商品名,单价,销售数量
姓名商品名销售总额
aa电视机5000
aa 冰箱8000
aa空调6000
aa19000
bb电视机8000
bb冰箱6000
bb空调 8000
bb22000
......
[解决办法]
&&创建t001
create table t001 (姓名 c(2),商品名 c(6),单价 n(4),数量 n(4))
insert into t001 values ( "aa ", "电视机 ",100,5)
insert into t001 values ( "bb ", "电视机 ",200,3)
insert into t001 values ( "aa ", "冰箱 ",300,4)
insert into t001 values ( "bb ", "冰箱 ",200,3)
&&使用临时表temp
select 姓名,商品名,sum(单价*数量) as 销售总额 from t001 group by 姓名,商品名 union select 姓名, " " as 商品名,sum(单价*数量) as 销售总额 from t001 group by 姓名 into table temp
select * from temp order by 姓名,商品名 desc
&&删除临时表
drop table temp