--又忘了group by 真晕--每年新添设备的数量、价格分类统计:select 年份=year(购买日期),类别,数量=count(*),价格 from 设备 group by year(购买日期),类别--每年的设备维修分类统计:select 维修年份=year(b.日期),a.类别,维修费用=sum(b.维修费用) from 设备 a join 设备维修 b on a.设备号=b.设备号 group by year(b.日期),a.类别
1. select 类别,count(设备号),sum(单价) from 设备 where year(购买日期)=year(getdate()) group by 类别2.select b.类别,count(a.设备号) from 设备维修 a ,设备 b where year(购买日期)=year(getdate()) and a.设备号=b.设备号 group by b.类别3.select b.类别,count(a.设备号)/count(b.设备号) from 设备维修 a ,设备 b where year(购买日期)=year(getdate()) and a.设备号=b.设备号 group by b.类别4.借用情况?
from 设备
group by year(购买日期),类别--每年的设备维修分类统计:select 维修年份=year(b.日期),a.类别,维修费用=sum(b.维修费用)
from 设备 a join 设备维修 b on a.设备号=b.设备号
group by year(b.日期),a.类别
select 类别,count(设备号),sum(单价) from 设备
where year(购买日期)=year(getdate())
group by 类别2.select b.类别,count(a.设备号) from 设备维修 a ,设备 b
where year(购买日期)=year(getdate())
and a.设备号=b.设备号
group by b.类别3.select b.类别,count(a.设备号)/count(b.设备号) from 设备维修 a ,设备 b
where year(购买日期)=year(getdate())
and a.设备号=b.设备号
group by b.类别4.借用情况?