-- 2024-05-07 维修表缺少字段
ALTER TABLE maintain_info ADD cost numeric(2,0) NULL;
EXEC sys.sp_addextendedproperty 'MS_Description', N'材料费用', 'schema', N'dbo', 'table', N'maintain_info', 'column', N'cost';
ALTER TABLE maintain_info ADD contents varchar(100) NULL;
EXEC sys.sp_addextendedproperty 'MS_Description', N'维保内容', 'schema', N'dbo', 'table', N'maintain_info', 'column', N'contents';
ALTER TABLE maintain_info ADD evaluate varchar(10) NULL;
EXEC sys.sp_addextendedproperty 'MS_Description', N'评价内容', 'schema', N'dbo', 'table', N'maintain_info', 'column', N'evaluate';

-- 训练集合：
select
    eds.cur_date,
    eds.building_id,
    isnull(eds.water_value,
           0) as water_value,
    isnull(eds.elect_value,
           0) as elect_value,
    isnull(convert(numeric(24,2),t1.water_level),
           0) as water_level
from
    energy_day_sum eds
        left join (
        select
            convert(date,
                    cur_date) as cur_date,
            building_id,
            avg(isnull(convert(numeric(24, 2), water_level), 0)) as water_level
        from
            history_data
        group by
            convert(date,
                    cur_date),
            building_id
    ) t1 on
                eds.cur_date = t1.cur_date and eds.building_id  = t1.building_id
where eds.building_id != '所有'
order by
    eds.building_id,
    eds.cur_date
