 
 
 --
--- Name: view_readings; Type: ACL; Schema: public; Owner: postgres
---
-
-REVOKE ALL ON TABLE view_readings FROM PUBLIC;
-REVOKE ALL ON TABLE view_readings FROM postgres;
-GRANT ALL ON TABLE view_readings TO postgres;
-GRANT ALL ON TABLE view_readings TO sepgroup;
-
-
---
--- Name: view_readings_with_meter_id; Type: ACL; Schema: public; Owner: postgres
---
-
-REVOKE ALL ON TABLE view_readings_with_meter_id FROM PUBLIC;
-REVOKE ALL ON TABLE view_readings_with_meter_id FROM postgres;
-GRANT ALL ON TABLE view_readings_with_meter_id TO postgres;
-GRANT ALL ON TABLE view_readings_with_meter_id TO sepgroup;
-
-
---
--- Name: view_readings_with_meter_id_unsorted_copy; Type: ACL; Schema: public; Owner: daniel
---
-
-REVOKE ALL ON TABLE view_readings_with_meter_id_unsorted_copy FROM PUBLIC;
-REVOKE ALL ON TABLE view_readings_with_meter_id_unsorted_copy FROM daniel;
-GRANT ALL ON TABLE view_readings_with_meter_id_unsorted_copy TO daniel;
-GRANT ALL ON TABLE view_readings_with_meter_id_unsorted_copy TO sepgroup;
-
-
---
 -- Name: view_register_records; Type: ACL; Schema: public; Owner: daniel
 --
 



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




--
-- Name: readings_by_meter_location_history; Type: VIEW; Schema: public; Owner: daniel
--

CREATE VIEW readings_by_meter_location_history AS
    SELECT "MeterLocationHistory".meter_name, "MeterLocationHistory".service_point_id, "MeterLocationHistory".service_point_latitude, "MeterLocationHistory".service_point_longitude, "MeterLocationHistory".location, "MeterLocationHistory".latitude, "MeterLocationHistory".longitude, "MeterLocationHistory".installed, "MeterLocationHistory".uninstalled, "Reading".channel, "Reading".raw_value, "Reading".value, "Reading".uom, "IntervalReadData".start_time, "Interval".end_time AS ird_end_time FROM (((("MeterLocationHistory" JOIN "MeterData" ON ((("MeterLocationHistory".meter_name)::bpchar = "MeterData".meter_name))) JOIN "IntervalReadData" ON (("MeterData".meter_data_id = "IntervalReadData".meter_data_id))) JOIN "Interval" ON (("IntervalReadData".interval_read_data_id = "Interval".interval_read_data_id))) JOIN "Reading" ON (((("Interval".interval_id = "Reading".interval_id) AND ("Interval".end_time >= "MeterLocationHistory".installed)) AND CASE WHEN ("MeterLocationHistory".uninstalled IS NULL) THEN true ELSE ("Interval".end_time <= "MeterLocationHistory".uninstalled) END)));


ALTER TABLE public.readings_by_meter_location_history OWNER TO daniel;

--
-- Name: VIEW readings_by_meter_location_history; Type: COMMENT; Schema: public; Owner: daniel
--

COMMENT ON VIEW readings_by_meter_location_history IS 'Readings limited by Meter Location History. @author Daniel Zhang (張道博)';


--
-- Name: readings_for_houses_without_pv; Type: VIEW; Schema: public; Owner: postgres
--

