问题是,你一条记录只卖一件商品?
如果时的话: 每年每个月
select datepart(year,date)*100+datepart(month,date) YEARMONTH,count(*) SPSL,distinct(employee) from shopp
group by employee
如果表中shopp记录的是商品数量: 每年每个月
select datepart(year,date)*100+datepart(month,date) YEARMONTH,sum(shopp) SPSL,distinct(employee) from shopp
group by employee
select employee,sum(shopp) as 商品数,CONVERT (char(6), date ,112) as 时间
from shopp
group by employee,时间
select employee,sum(shopp) as 商品数,CONVERT (char(6), date ,112) as 时间
from shopp
group by employee,时间
having sum(shopp) >3
建议你行列转换,把列换成商品,员工和时间(1-12月)共14列来做,至于怎么行列转换,去网上一搜一堆,具体不写了
update
配件
set
套数
=(
select
round(min(a))
from
((select
零件1/1
as
a
from
配件)
union(select
零件2/2
as
a
from
配件)
union
(select
零件3/3
as
a
from
配件))
);