 
 
 --
+-- Name: cd_energy_voltages_for_houses_with_pv; Type: VIEW; Schema: public; Owner: eileen
+--
+
+CREATE VIEW cd_energy_voltages_for_houses_with_pv AS
+    SELECT cd_meter_ids_for_houses_with_pv_with_locations.device_util_id, view_readings_with_meter_id_unsorted.end_time, max(CASE WHEN (view_readings_with_meter_id_unsorted.channel = (1)::smallint) THEN view_readings_with_meter_id_unsorted.value ELSE NULL::real END) AS "Energy to House kwH", zero_to_null(max(CASE WHEN (view_readings_with_meter_id_unsorted.channel = (4)::smallint) THEN view_readings_with_meter_id_unsorted.value ELSE NULL::real END)) AS "Voltage", max(cd_meter_ids_for_houses_with_pv_with_locations.service_pt_longitude) AS service_pt_longitude, max(cd_meter_ids_for_houses_with_pv_with_locations.service_pt_latitude) AS service_pt_latitude, max((cd_meter_ids_for_houses_with_pv_with_locations.address1)::text) AS address1 FROM (cd_meter_ids_for_houses_with_pv_with_locations JOIN view_readings_with_meter_id_unsorted ON (((cd_meter_ids_for_houses_with_pv_with_locations.device_util_id)::bpchar = view_readings_with_meter_id_unsorted.meter_name))) WHERE ((view_readings_with_meter_id_unsorted.channel = (1)::smallint) OR (view_readings_with_meter_id_unsorted.channel = (4)::smallint)) GROUP BY cd_meter_ids_for_houses_with_pv_with_locations.device_util_id, view_readings_with_meter_id_unsorted.end_time;
+
+
+ALTER TABLE public.cd_energy_voltages_for_houses_with_pv OWNER TO eileen;
+
+--
+-- Name: count_of_event_duplicates; Type: VIEW; Schema: public; Owner: daniel
+--
+
+CREATE VIEW count_of_event_duplicates AS
+    SELECT "Event".event_time, "MeterData".meter_data_id, "EventData".event_data_id, (count(*) - 1) AS "Duplicate Count" FROM (("MeterData" JOIN "EventData" ON (("MeterData".meter_data_id = "EventData".meter_data_id))) JOIN "Event" ON (("EventData".event_data_id = "Event".event_data_id))) GROUP BY "Event".event_time, "MeterData".meter_data_id, "EventData".event_data_id HAVING ((count(*) - 1) > 0) ORDER BY "Event".event_time;
+
+
+ALTER TABLE public.count_of_event_duplicates OWNER TO daniel;
+
+--
+-- Name: VIEW count_of_event_duplicates; Type: COMMENT; Schema: public; Owner: daniel
+--
+
+COMMENT ON VIEW count_of_event_duplicates IS 'Report of counts of event duplicates. @author Daniel Zhang (張道博)';
+
+
+--
 -- Name: count_of_readings_and_meters_by_day; Type: VIEW; Schema: public; Owner: daniel
 --
 



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

REVOKE ALL ON TABLE "YU_voltages_for_houses_without_PV" FROM PUBLIC;
REVOKE ALL ON TABLE "YU_voltages_for_houses_without_PV" FROM eileen;
GRANT ALL ON TABLE "YU_voltages_for_houses_without_PV" TO eileen;
GRANT ALL ON TABLE "YU_voltages_for_houses_without_PV" TO sepgroup;


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

REVOKE ALL ON TABLE "YU_energy_voltages_for_houses_without_PV" FROM PUBLIC;
REVOKE ALL ON TABLE "YU_energy_voltages_for_houses_without_PV" FROM eileen;
GRANT ALL ON TABLE "YU_energy_voltages_for_houses_without_PV" TO eileen;
GRANT ALL ON TABLE "YU_energy_voltages_for_houses_without_PV" TO sepgroup;


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

REVOKE ALL ON TABLE "YU_one_January" FROM PUBLIC;
REVOKE ALL ON TABLE "YU_one_January" FROM eileen;
GRANT ALL ON TABLE "YU_one_January" TO eileen;
GRANT ALL ON TABLE "YU_one_January" TO sepgroup;


--



--
-- 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: count_of_event_duplicates; Type: ACL; Schema: public; Owner: daniel
--

REVOKE ALL ON TABLE count_of_event_duplicates FROM PUBLIC;
REVOKE ALL ON TABLE count_of_event_duplicates FROM daniel;
GRANT ALL ON TABLE count_of_event_duplicates TO daniel;
GRANT ALL ON TABLE count_of_event_duplicates TO sepgroup;


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

