diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2023-08-06 07:48:11 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2023-08-06 07:48:11 +0000 |
commit | 379c6d1f52e1d311867c4f789dc389da1d9af898 (patch) | |
tree | c9ca62eb7b8b7e861cc67248850db220ad0881c9 /tests/fixtures/optimizer/optimizer.sql | |
parent | Releasing debian version 17.7.0-1. (diff) | |
download | sqlglot-379c6d1f52e1d311867c4f789dc389da1d9af898.tar.xz sqlglot-379c6d1f52e1d311867c4f789dc389da1d9af898.zip |
Merging upstream version 17.9.1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | tests/fixtures/optimizer/optimizer.sql | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/tests/fixtures/optimizer/optimizer.sql b/tests/fixtures/optimizer/optimizer.sql index 14f5cfe..981e052 100644 --- a/tests/fixtures/optimizer/optimizer.sql +++ b/tests/fixtures/optimizer/optimizer.sql @@ -638,7 +638,7 @@ SELECT FROM "users" AS "u" CROSS JOIN LATERAL ( SELECT - "l"."log_date" + "l"."log_date" AS "log_date" FROM "logs" AS "l" WHERE "l"."log_date" <= 100 AND "l"."user_id" = "u"."user_id" @@ -890,3 +890,20 @@ FROM ( JOIN "y" AS "y" ON "x"."a" = "y"."c" ); + +# title: replace scalar subquery, wrap resulting column in a MAX +SELECT a, SUM(c) / (SELECT SUM(c) FROM y) * 100 AS foo FROM y INNER JOIN x ON y.b = x.b GROUP BY a; +WITH "_u_0" AS ( + SELECT + SUM("y"."c") AS "_col_0" + FROM "y" AS "y" +) +SELECT + "x"."a" AS "a", + SUM("y"."c") / MAX("_u_0"."_col_0") * 100 AS "foo" +FROM "y" AS "y" +CROSS JOIN "_u_0" AS "_u_0" +JOIN "x" AS "x" + ON "y"."b" = "x"."b" +GROUP BY + "x"."a"; |