题解 | 智能家居设备高能耗异常监控分析

智能家居设备高能耗异常监控分析

https://www.nowcoder.com/practice/d66ad4fcf3d54852832099d1674fe1c3

with total_avg_kwh as (
select
sd.category,
round(avg(el.usage_kwh),2) as avg_kwh
from
energy_logs el
left join
smart_devices sd on el.device_id=sd.device_id
where el.log_timestamp between'2021-01-01' and '2025-01-31'
group by sd.category
),
device_kwh as (
    select 
    sd.category,
    sd.device_id,
    sd.device_name,
    sd.location,
    round(sum(el.usage_kwh),2) as total_usage
    from
    energy_logs el
    left join
    smart_devices sd on el.device_id=sd.device_id
    where date_format(el.log_timestamp,'%Y-%m')='2025-01'
    group by sd.category,sd.device_id,sd.device_name,sd.location
),
info as (
select 
device_id,
device_name,
upper(replace(location,' ','_' )) as location_code,
total_usage,
case when total_usage>=50.00 then 'High Load' else 'Normal' end as efficiency_level
from 
device_kwh dk
left join
total_avg_kwh tk on dk.category=tk.category
where total_usage>avg_kwh
order by total_usage desc,device_id
)

select
device_name,
location_code,
total_usage,
efficiency_level
from
info;













全部评论

相关推荐

02-14 12:40
门头沟学院 Java
程序员花海:1.面试要求必须Java笔试不一定 2.难度对等秋招 远超于日常实习是因为同一批次且转正很多 竞争压力大 3.第一个加点指标,上线了就把接口性能加上去 使用本地缓存这个不算亮点 只是技术选型,要把为什么采用这个和背后的思考写出来而不是单纯堆叠技术没意义 4.八股要一直看 很容易忘记 5.拼团交易这个老问题 堆积技术 另外建议你把奖项合并到教育背景 没必要拆出来放最后
我的简历长这样
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务