34,594
社区成员
发帖
与我相关
我的任务
分享
if OBJECT_ID('tb') is not null drop table tb
go
create table tb(Date1 datetime, ctype varchar(10),qnt float,pri float)
insert tb
select '2009-1-1', '库存', 100, 8 union all
select '2009-1-3', '出货', 20, 12 union all
select '2009-1-5', '进货', 50, 10
if OBJECT_ID('tb') is not null drop table tb
go
create table tb(Date1 datetime, ctype varchar(10),qnt float,pri float)
insert tb
select '2009-1-1', '进货', 100, 8 union all
select '2009-1-3', '出货', 20, 12 union all
select '2009-1-5', '进货', 50, 10 union all
select '2009-1-7', '出货', 30, 15 union all
select '2009-1-8', '进货', 10, 8
进货的价格不是成本价,
select date1,avg(pri) pri from tb where ctype='进货'
group by date1