WITH "user" AS (VALUES(1, 'taro'), (2, 'jiro'))
SELECT JSON_AGG("user")
FROM "user";
json_agg
require 'google-cloud-bigquery' | |
def main(str) | |
n, inputs = str.split(',').yield_self { |n, inputs| [n, inputs.chars] } | |
tables = inputs.map.with_index { |symbol, i| | |
<<~SQL | |
t#{i+1} AS ( | |
SELECT ARRAY_CONCAT(t#{i}.nums, [rules.`no`]) AS nums | |
, t#{i}.angle + rules.angle AS angle |
require 'pg' | |
RULES = { | |
'a' => [0, 1, -1, 0], | |
'b' => [0, 1, 0, -1, 0] | |
} | |
ANS = '0+-' | |
def main(str) |
require 'pg' | |
def main(str) | |
n, inputs = str.split(',') | |
inputs_sql = inputs.chars.map { |s| "('#{s}')" }.join(', ') | |
sql = <<~SQL | |
WITH RECURSIVE rules(symbol, "no", angle) AS ( | |
VALUES('a', 1, 0), ('a', 2, 60), ('a', 3, -60), ('a', 4, 0), | |
('b', 1, 0), ('b', 2, 60), ('b', 3, 0), ('b', 4, -60), ('b', 5, 0)) |
CREATE TEMP TABLE hoge (id integer, name text); | |
WITH t(id, name) AS (VALUES (1, 'hoge'), (2, 'fuga'), (3, 'piyo')) | |
, t2 AS (INSERT INTO hoge SELECT id, name FROM t) | |
INSERT INTO hoge SELECT id * 10, name FROM t; | |
SELECT * FROM hoge; | |
-- id | name | |
-- ----+------ |
#standardsql | |
WITH a AS ( | |
SELECT * FROM UNNEST([1,2,3,4]) AS n | |
), b AS ( | |
SELECT * FROM UNNEST([4,5,6,7]) AS n) | |
SELECT * FROM a |
WITH T(ID, A, TIME) AS ( | |
VALUES (1, 2, '2017-12-10') | |
, (2, 3, '2017-12-10') | |
, (3, 2, '2017-12-10') | |
, (4, 4, '2017-12-11') | |
, (5, 4, '2017-12-11') | |
, (6, 2, '2017-12-11')) | |
SELECT A | |
, COUNT(A) AS cnt |
require 'pg' | |
def main(str) | |
start, goal = str.chars | |
PG.connect.exec_params(<<~SQL, [start, goal]).first['cnt'] | |
WITH RECURSIVE patterns("from", "to") AS ( | |
VALUES ('0', '1'), ('0', '6'), ('1', '0'), ('1', '7'), ('2', '3'), | |
('3', '2'), ('3', '4'), ('3', '9'), ('4', '3'), ('4', '5'), | |
('5', '4'), ('5', 'B'), ('6', '0'), ('6', 'C'), ('7', '1'), | |
('7', '8'), ('8', '7'), ('8', '9'), ('9', '8'), ('9', '3'), |
WITH local_card_ids(id, "order") AS (VALUES(1, 0), (2, 1), (3, 2), (4, 3), (5, 4)) | |
SELECT cache.cards.* | |
FROM cache.cards | |
JOIN local_card_ids USING(id) | |
ORDER BY local_card_ids."order"; | |
const electron = require('electron'); | |
const app = electron.app; | |
const BrowserWindow = electron.BrowserWindow; | |
let mainWindow = null; | |
app.on('window-all-closed', function() { | |
if (process.platform != 'darwin') { | |
app.quit(); | |
} | |
}); |