File tree Expand file tree Collapse file tree 1 file changed +14
-14
lines changed
docs/stable/sql/expressions Expand file tree Collapse file tree 1 file changed +14
-14
lines changed Original file line number Diff line number Diff line change @@ -134,37 +134,37 @@ SELECT COLUMNS(*) + COLUMNS(*) FROM numbers;
134134``` sql
135135SELECT *
136136FROM (
137- SELECT 0 AS x, 0 AS y
137+ SELECT ' a ' , ' a '
138138 UNION ALL
139- SELECT 0 AS x, 1 AS y
139+ SELECT ' a ' , ' b '
140140 UNION ALL
141- SELECT 1 AS x, 1 AS y
142- )
143- WHERE COLUMNS(* ) > 0 ; -- equivalent to: x > 0 AND y > 1
141+ SELECT ' b ' , ' b '
142+ ) _(x, y)
143+ WHERE COLUMNS(* ) = ' a ' ; -- equivalent to: x = 'a' AND y = 'a'
144144```
145145
146146| x | y |
147147| --:| --:|
148- | 1 | 1 |
148+ | a | a |
149149
150- To combine using the logical ` OR ` operator, you can ` UNPACK ` the ` COLUMNS ` expression into the variadic ` greatest ` function.
150+ To combine conditions using the logical ` OR ` operator, you can ` UNPACK ` the ` COLUMNS ` expression into the variadic ` greatest ` function.
151151
152152``` sql
153153SELECT *
154154FROM (
155- SELECT 0 AS x, 0 AS y
155+ SELECT ' a ' , ' a '
156156 UNION ALL
157- SELECT 0 AS x, 1 AS y
157+ SELECT ' a ' , ' b '
158158 UNION ALL
159- SELECT 1 AS x, 1 AS y
160- )
161- WHERE greatest(UNPACK(COLUMNS(* ) > 0 )); -- equivalent to: x > 0 OR y > 1
159+ SELECT ' b ' , ' b '
160+ ) _(x, y)
161+ WHERE greatest(UNPACK(COLUMNS(* ) = ' a ' )); -- equivalent to: x = 'a' OR y = 'a'
162162```
163163
164164| x | y |
165165| --:| --:|
166- | 0 | 1 |
167- | 1 | 1 |
166+ | a | a |
167+ | a | b |
168168
169169### Regular Expressions in a ` COLUMNS ` Expression
170170
You can’t perform that action at this time.
0 commit comments