--今年新增设备的数量,价格统计select 类别,数量=count(*),价格
from 设备
where datediff(year,购买日期,getdate())=0

解决方案 »

  1.   

    --又忘了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.类别
      

  2.   

    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.借用情况?
      

  3.   

    select * from 设备借用:)是这样吗?难道