Created
November 4, 2013 22:28
-
-
Save workmaster2n/7310317 to your computer and use it in GitHub Desktop.
integer issues
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| SELECT * FROM tracked_points | |
| INNER JOIN tags ON tags.frequency = tracked_points.frequency | |
| INNER JOIN worker_tags ON worker_tags.tag_id = tags.id | |
| ORDER BY recorded_at DESC LIMIT 100 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| CREATE TABLE public.tracked_points | |
| ( | |
| id integer NOT NULL DEFAULT nextval('tracked_points_id_seq'::regclass), | |
| recorded_at timestamp without time zone, | |
| worker_id integer, | |
| created_at timestamp without time zone NOT NULL, | |
| updated_at timestamp without time zone NOT NULL, | |
| location_id integer NOT NULL, | |
| session_id integer, | |
| frequency integer, | |
| worker_id_checked_at timestamp without time zone, | |
| zone_checked_at timestamp without time zone, | |
| CONSTRAINT tracked_points_pkey PRIMARY KEY (id) | |
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| UPDATE tracked_points SET worker_id = worker_tags.worker_id | |
| FROM tags LEFT JOIN worker_tags ON tags.id = worker_tags.tag_id | |
| WHERE (tags.frequency = tracked_points.frequency OR worker_tags.id IS NULL) | |
| AND tracked_points.worker_id_checked_at IS NULL |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment