Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Query suggestion #32

Closed
chekos opened this issue Jul 8, 2020 · 1 comment
Closed

Query suggestion #32

chekos opened this issue Jul 8, 2020 · 1 comment
Assignees
Labels
suggestion A canned query suggestion (to be included by default in future deployment)

Comments

@chekos
Copy link
Owner

chekos commented Jul 8, 2020

Stops within civil twilight by agency

query

SELECT
  AGENCY_NAME,
  IN_TWILIGHT,
  COUNT(*) as N
FROM
  (
    SELECT
      main.UNIQUE_ID,
      main.AGENCY_NAME,
      main.DATE_OF_STOP,
      main.CLOSEST_CITY,
      TIME_OF_STOP,
      twilight.CTWILIGHT_BEGIN as twilight_begin,
      twilight.CTWILIGHT_END as twilight_end,
      CASE
        WHEN TIME_OF_STOP > twilight.CTWILIGHT_BEGIN
        AND TIME_OF_STOP < twilight.CTWILIGHT_END THEN "Within civil twilight"
        ELSE "in the dark..."
      END as IN_TWILIGHT
    FROM
      aa_main_table as main
      INNER JOIN civil_twilight_hours as twilight ON twilight.DATE_OF_STOP = main.DATE_OF_STOP
      AND twilight.CLOSEST_CITY = main.CLOSEST_CITY
  )
GROUP BY 
  AGENCY_NAME, IN_TWILIGHT
@chekos chekos added the suggestion A canned query suggestion (to be included by default in future deployment) label Jul 8, 2020
@chekos chekos self-assigned this Jul 8, 2020
@chekos
Copy link
Owner Author

chekos commented Jul 8, 2020

Closed with #31 too

@chekos chekos closed this as completed Jul 8, 2020
@chekos chekos mentioned this issue Jul 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
suggestion A canned query suggestion (to be included by default in future deployment)
Projects
None yet
Development

No branches or pull requests

1 participant