presto with
withよくわかんなかったけど、サブクエリの簡素化だね、やっていることは。
WITH dataset AS ( SELECT * FROM ( VALUES (1, 'A'), (2, 'B'), (3, 'C'), (4, 'D'), (5, 'A'), (6, 'B'), (7, 'C'), (9, 'A'), (10, 'B'),(11, 'C'), (13, 'A'),(14, 'B'),(15, 'C'), (17, 'A'),(18, 'B'),(19, 'C'), (21, 'A'),(22, 'B'),(23, 'C'), (25, 'A'),(26, 'B') ) AS t ) SELECT * -- assuming we want to sample 25% of records FROM dataset TABLESAMPLE BERNOULLI(25)
The WITH clause defines named relations for use within a query. It allows flattening nested queries or simplifying subqueries. For example, the following queries are equivalent: