 --
 
 COMMENT ON VIEW dz_monthly_energy_summary_for_nonpv_service_points IS 'Monthly energy summary for Non-PV service points. @author Daniel Zhang (張道博)';
+
+
+--
+-- Name: dz_pv_interval_ids; Type: VIEW; Schema: public; Owner: postgres
+--
+
+CREATE VIEW dz_pv_interval_ids AS
+    SELECT readings_unfiltered.interval_id, readings_unfiltered.value, readings_unfiltered.channel, readings_unfiltered.end_time, readings_unfiltered.meter_name FROM (nonpv_mlh JOIN readings_unfiltered ON (((nonpv_mlh.meter_name)::bpchar = readings_unfiltered.meter_name))) WHERE ((readings_unfiltered.channel = 2::smallint) AND (readings_unfiltered.value > 0::real));
+
+
+ALTER TABLE public.dz_pv_interval_ids OWNER TO postgres;
+
+--
+-- Name: VIEW dz_pv_interval_ids; Type: COMMENT; Schema: public; Owner: postgres
+--
+
+COMMENT ON VIEW dz_pv_interval_ids IS 'Provides interval IDs for readings where channel 2 has energy > 0.0. @author Daniel Zhang (張道博)';
+
+
+--
+-- Name: dz_pv_readings_in_nonpv_mlh; Type: VIEW; Schema: public; Owner: postgres
+--
+
+CREATE VIEW dz_pv_readings_in_nonpv_mlh AS
+    SELECT nonpv_mlh.service_point_id, readings_unfiltered.end_time, readings_unfiltered.meter_name, readings_unfiltered.channel, readings_unfiltered.raw_value, readings_unfiltered.value, readings_unfiltered.uom, readings_unfiltered.start_time, readings_unfiltered.ird_end_time, readings_unfiltered.meter_data_id, readings_unfiltered.interval_id FROM ((dz_pv_interval_ids JOIN readings_unfiltered ON ((dz_pv_interval_ids.interval_id = readings_unfiltered.interval_id))) JOIN nonpv_mlh ON ((dz_pv_interval_ids.meter_name = (nonpv_mlh.meter_name)::bpchar)));
+
+
+ALTER TABLE public.dz_pv_readings_in_nonpv_mlh OWNER TO postgres;
+
+--
+-- Name: VIEW dz_pv_readings_in_nonpv_mlh; Type: COMMENT; Schema: public; Owner: postgres
+--
+
+COMMENT ON VIEW dz_pv_readings_in_nonpv_mlh IS 'A report of readings that are in the MLH but do not have PV service points IDs. @author Daniel Zhang (張道博)';
+
+
+--
+-- Name: dz_summary_pv_readings_in_nonpv_mlh; Type: VIEW; Schema: public; Owner: postgres
+--
+
+CREATE VIEW dz_summary_pv_readings_in_nonpv_mlh AS
+    SELECT dz_pv_readings_in_nonpv_mlh.meter_name, dz_pv_readings_in_nonpv_mlh.service_point_id, min(dz_pv_readings_in_nonpv_mlh.end_time) AS first_reading_time, max(dz_pv_readings_in_nonpv_mlh.end_time) AS last_reading_time FROM dz_pv_readings_in_nonpv_mlh GROUP BY dz_pv_readings_in_nonpv_mlh.meter_name, dz_pv_readings_in_nonpv_mlh.service_point_id;
+
+
+ALTER TABLE public.dz_summary_pv_readings_in_nonpv_mlh OWNER TO postgres;
+
+--
+-- Name: VIEW dz_summary_pv_readings_in_nonpv_mlh; Type: COMMENT; Schema: public; Owner: postgres
+--
+
+COMMENT ON VIEW dz_summary_pv_readings_in_nonpv_mlh IS 'Summary of service points and meters in the MLH that have PV readings but do not have PV Service Point IDs. @author Daniel Zhang (張道博)';
 
 
 --



--
-- Name: readings_unfiltered; Type: ACL; Schema: public; Owner: daniel
--

REVOKE ALL ON TABLE readings_unfiltered FROM PUBLIC;
REVOKE ALL ON TABLE readings_unfiltered FROM daniel;
GRANT ALL ON TABLE readings_unfiltered TO daniel;
GRANT ALL ON TABLE readings_unfiltered TO sepgroup;
GRANT ALL ON TABLE readings_unfiltered TO postgres;


--
-- Name: cd_energy_voltages_for_houses_with_pv; Type: ACL; Schema: public; Owner: eileen
--

REVOKE ALL ON TABLE cd_energy_voltages_for_houses_with_pv FROM PUBLIC;
REVOKE ALL ON TABLE cd_energy_voltages_for_houses_with_pv FROM eileen;
GRANT ALL ON TABLE cd_energy_voltages_for_houses_with_pv TO eileen;
GRANT ALL ON TABLE cd_energy_voltages_for_houses_with_pv TO sepgroup;





--
-- Name: dz_pv_interval_ids; Type: ACL; Schema: public; Owner: postgres
--

REVOKE ALL ON TABLE dz_pv_interval_ids FROM PUBLIC;
REVOKE ALL ON TABLE dz_pv_interval_ids FROM postgres;
GRANT ALL ON TABLE dz_pv_interval_ids TO postgres;
GRANT ALL ON TABLE dz_pv_interval_ids TO sepgroup;


--
-- Name: dz_pv_readings_in_nonpv_mlh; Type: ACL; Schema: public; Owner: postgres
--

REVOKE ALL ON TABLE dz_pv_readings_in_nonpv_mlh FROM PUBLIC;
REVOKE ALL ON TABLE dz_pv_readings_in_nonpv_mlh FROM postgres;
GRANT ALL ON TABLE dz_pv_readings_in_nonpv_mlh TO postgres;
GRANT ALL ON TABLE dz_pv_readings_in_nonpv_mlh TO sepgroup;


--
-- Name: dz_summary_pv_readings_in_nonpv_mlh; Type: ACL; Schema: public; Owner: postgres
--

REVOKE ALL ON TABLE dz_summary_pv_readings_in_nonpv_mlh FROM PUBLIC;
REVOKE ALL ON TABLE dz_summary_pv_readings_in_nonpv_mlh FROM postgres;
GRANT ALL ON TABLE dz_summary_pv_readings_in_nonpv_mlh TO postgres;
GRANT ALL ON TABLE dz_summary_pv_readings_in_nonpv_mlh TO sepgroup;


--
-- Name: event_data_id_seq; Type: ACL; Schema: public; Owner: sepgroup
--

