Skip to content

Commit

Permalink
Add views for weeks and months #89
Browse files Browse the repository at this point in the history
  • Loading branch information
radumas committed Dec 11, 2017
1 parent db7dace commit 6fbf257
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions bluetooth/sql/create-week-months-views.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
CREATE OR REPLACE VIEW king_pilot.pilot_weeks AS
SELECT week, row_number() OVER() as week_number
FROM (SELECT DISTINCT ON(date_trunc('week', dt)::DATE) date_trunc('week', dt)::DATE as week
FROM king_pilot.dash_daily_dev
WHERE dt >= '2017-11-13' )a
ORDER BY week;

CREATE OR REPLACE VIEW king_pilot.pilot_months AS
SELECT month, row_number() OVER() as month_number
FROM (SELECT DISTINCT ON(date_trunc('month', dt)::DATE) date_trunc('month', dt)::DATE as month
FROM king_pilot.dash_daily
WHERE dt >= '2017-11-13' )a
ORDER BY month;

0 comments on commit 6fbf257

Please sign in to comment.