This file contains 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
# Calculate the MEDIAN in BigQuery; standard-sql; 2020-06-20 | |
# @see http://www.pascallandau.com/bigquery-snippets/calculate-median/ | |
WITH data as ( | |
SELECT | |
1 as id, | |
"2020-06-20" as day, | |
10 as quantity | |
UNION ALL SELECT 2,"2020-06-20", 15 | |
UNION ALL SELECT 1,"2020-06-21",5 | |
UNION ALL SELECT 2,"2020-06-21",10 |
This file contains 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
#standardSQL | |
# Extract query parameters from a URL as ARRAY in BigQuery; standard-sql; 2018-04-08 | |
# @see http://www.pascallandau.com/bigquery-snippets/extract-url-parameters-array/ | |
WITH examples AS ( | |
SELECT 1 AS id, | |
'?foo=bar' AS query, | |
'simple' AS description | |
UNION ALL SELECT 2, '?foo=bar&bar=baz', 'multiple params' | |
UNION ALL SELECT 3, '?foo[]=bar&foo[]=baz', 'arrays' | |
UNION ALL SELECT 4, '', 'no query' |
This file contains 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
#!/usr/bin/env php | |
<?php | |
$intro = <<<TEXT | |
Helper command to export data for an arbitrary mysql query into a CSV file. | |
Especially helpful if the use of "SELECT ... INTO OUTFILE" is not an option, e.g. | |
because the mysql server is running on a remote host. | |
Usage example: | |
./mysql2csv --file="/tmp/result.csv" --query='SELECT 1 as foo, 2 as bar;' --user="username" --password="password" |
OlderNewer