Skip to content

Commit

Permalink
Small H2 query improvement
Browse files Browse the repository at this point in the history
  • Loading branch information
tunetheweb committed Aug 29, 2021
1 parent 5a6c6f9 commit b806458
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions sql/timeseries/h2.sql
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ SELECT
SUBSTR(_TABLE_SUFFIX, 0, 10) AS date,
UNIX_DATE(CAST(REPLACE(SUBSTR(_TABLE_SUFFIX, 0, 10), '_', '-') AS DATE)) * 1000 * 60 * 60 * 24 AS timestamp,
IF(ENDS_WITH(_TABLE_SUFFIX, 'desktop'), 'desktop', 'mobile') AS client,
ROUND(SUM(IF(JSON_EXTRACT_SCALAR(payload, '$._protocol') = 'HTTP/2', 1, 0)) * 100 / COUNT(0), 2) AS percent
ROUND(SUM(IF(protocol = 'HTTP/2', 1, 0)) * 100 / COUNT(0), 2) AS percent
FROM
(SELECT page AS url, payload, _TABLE_SUFFIX AS _TABLE_SUFFIX FROM `httparchive.requests.*`)
(SELECT page AS url, JSON_EXTRACT_SCALAR(payload, '$._protocol') AS protocol, _TABLE_SUFFIX AS _TABLE_SUFFIX FROM `httparchive.requests.*`)
GROUP BY
date,
timestamp,
Expand Down

0 comments on commit b806458

Please sign in to comment.