Skip to content

Commit 1b678d1

Browse files
authored
Add a "pragma pg" example (#6573)
1 parent bee1387 commit 1b678d1

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

book/src/super-sql/declarations/pragmas.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,3 +49,37 @@ values {
4949
{a:"a",b:error("missing")}
5050
{a:[2],b:1}
5151
```
52+
53+
---
54+
55+
_Use default `GROUP BY` precedence (no `pragma`) to group by the alias "x" that refers to constant 0_
56+
57+
```mdtest-spq
58+
# spq
59+
SELECT 0 AS x, COUNT(*) AS n GROUP BY x
60+
# input
61+
{x:1}
62+
{x:2}
63+
{x:1}
64+
{x:2}
65+
# expected output
66+
{x:0,n:4}
67+
```
68+
69+
---
70+
71+
_Use PostgreSQL `GROUP BY` precedence to group by the source column "x" (not the alias)_
72+
73+
```mdtest-spq
74+
# spq
75+
pragma pg = true
76+
SELECT 0 AS x, COUNT(*) AS n GROUP BY x
77+
# input
78+
{x:1}
79+
{x:2}
80+
{x:1}
81+
{x:2}
82+
# expected output
83+
{x:0,n:2}
84+
{x:0,n:2}
85+
```

0 commit comments

Comments
 (0)