@@ -36,7 +36,7 @@ The general execution of `SELECT` is as follows:
36
36
37
37
As with a table, every output column of a `SELECT` has a name which can be either specified per column through the `AS` keyword :
38
38
39
- [" source"," sql",subs="attributes,callouts,macros" ]
39
+ [source, sql]
40
40
----
41
41
include-tagged::{sql-specs}/docs.csv-spec[selectColumnAlias]
42
42
----
@@ -46,14 +46,14 @@ which is why it is recommended to specify it.
46
46
47
47
assigned by {es-sql} if no name is given:
48
48
49
- [" source"," sql",subs="attributes,callouts,macros" ]
49
+ [source, sql]
50
50
----
51
51
include-tagged::{sql-specs}/docs.csv-spec[selectInline]
52
52
----
53
53
54
54
or if it's a simple column reference, use its name as the column name:
55
55
56
- [" source"," sql",subs="attributes,callouts,macros" ]
56
+ [source, sql]
57
57
----
58
58
include-tagged::{sql-specs}/docs.csv-spec[selectColumn]
59
59
----
@@ -63,7 +63,7 @@ include-tagged::{sql-specs}/docs.csv-spec[selectColumn]
63
63
64
64
To select all the columns in the source, one can use `*`:
65
65
66
- [" source"," sql",subs="attributes,callouts,macros" ]
66
+ [source, sql]
67
67
----
68
68
include-tagged::{sql-specs}/docs.csv-spec[wildcardWithOrder]
69
69
----
@@ -90,22 +90,22 @@ Represents the name (optionally qualified) of an existing table, either a concre
90
90
91
91
If the table name contains special SQL characters (such as `.`,`-`,etc...) use double quotes to escape them:
92
92
93
- [" source"," sql",subs="attributes,callouts,macros" ]
93
+ [source, sql]
94
94
----
95
95
include-tagged::{sql-specs}/docs.csv-spec[fromTableQuoted]
96
96
----
97
97
98
98
The name can be a <<multi-index, pattern>> pointing to multiple indices (likely requiring quoting as mentioned above) with the restriction that *all* resolved concrete tables have **exact mapping**.
99
99
100
- [" source"," sql",subs="attributes,callouts,macros" ]
100
+ [source, sql]
101
101
----
102
102
include-tagged::{sql-specs}/docs.csv-spec[fromTablePatternQuoted]
103
103
----
104
104
105
105
`alias`::
106
106
A substitute name for the `FROM` item containing the alias. An alias is used for brevity or to eliminate ambiguity. When an alias is provided, it completely hides the actual name of the table and must be used in its place.
107
107
108
- [" source"," sql",subs="attributes,callouts,macros" ]
108
+ [source, sql]
109
109
----
110
110
include-tagged::{sql-specs}/docs.csv-spec[fromTableAlias]
111
111
----
@@ -127,7 +127,7 @@ where:
127
127
128
128
Represents an expression that evaluates to a `boolean`. Only the rows that match the condition (to `true`) are returned.
129
129
130
- [" source"," sql",subs="attributes,callouts,macros" ]
130
+ [source, sql]
131
131
----
132
132
include-tagged::{sql-specs}/docs.csv-spec[basicWhere]
133
133
----
@@ -151,28 +151,28 @@ Represents an expression on which rows are being grouped _on_. It can be a colum
151
151
152
152
A common, group by column name:
153
153
154
- [" source"," sql",subs="attributes,callouts,macros" ]
154
+ [source, sql]
155
155
----
156
156
include-tagged::{sql-specs}/docs.csv-spec[groupByColumn]
157
157
----
158
158
159
159
Grouping by output ordinal:
160
160
161
- [" source"," sql",subs="attributes,callouts,macros" ]
161
+ [source, sql]
162
162
----
163
163
include-tagged::{sql-specs}/docs.csv-spec[groupByOrdinal]
164
164
----
165
165
166
166
Grouping by alias:
167
167
168
- [" source"," sql",subs="attributes,callouts,macros" ]
168
+ [source, sql]
169
169
----
170
170
include-tagged::{sql-specs}/docs.csv-spec[groupByAlias]
171
171
----
172
172
173
173
And grouping by column expression (typically used along-side an alias):
174
174
175
- [" source"," sql",subs="attributes,callouts,macros" ]
175
+ [source, sql]
176
176
----
177
177
include-tagged::{sql-specs}/docs.csv-spec[groupByExpression]
178
178
----
@@ -181,21 +181,21 @@ When a `GROUP BY` clause is used in a `SELECT`, _all_ output expressions must be
181
181
182
182
To wit:
183
183
184
- [" source"," sql",subs="attributes,callouts,macros" ]
184
+ [source, sql]
185
185
----
186
186
include-tagged::{sql-specs}/docs.csv-spec[groupByAndAgg]
187
187
----
188
188
189
189
Expressions over aggregates used in output:
190
190
191
- [" source"," sql",subs="attributes,callouts,macros" ]
191
+ [source, sql]
192
192
----
193
193
include-tagged::{sql-specs}/docs.csv-spec[groupByAndAggExpression]
194
194
----
195
195
196
196
Multiple aggregates used:
197
197
198
- [" source"," sql",subs="attributes,callouts,macros" ]
198
+ [source, sql]
199
199
----
200
200
include-tagged::{sql-specs}/docs.csv-spec[groupByAndMultipleAggs]
201
201
----
@@ -209,14 +209,14 @@ As such, the query emits only a single row (as there is only a single group).
209
209
210
210
A common example is counting the number of records:
211
211
212
- [" source"," sql",subs="attributes,callouts,macros" ]
212
+ [source, sql]
213
213
----
214
214
include-tagged::{sql-specs}/docs.csv-spec[groupByImplicitCount]
215
215
----
216
216
217
217
Of course, multiple aggregations can be applied:
218
218
219
- [" source"," sql",subs="attributes,callouts,macros" ]
219
+ [source, sql]
220
220
----
221
221
include-tagged::{sql-specs}/docs.csv-spec[groupByImplicitMultipleAggs]
222
222
----
@@ -243,14 +243,14 @@ Both `WHERE` and `HAVING` are used for filtering however there are several signi
243
243
. `WHERE` works on individual *rows*, `HAVING` works on the *groups* created by ``GROUP BY``
244
244
. `WHERE` is evaluated *before* grouping, `HAVING` is evaluated *after* grouping
245
245
246
- [" source"," sql",subs="attributes,callouts,macros" ]
246
+ [source, sql]
247
247
----
248
248
include-tagged::{sql-specs}/docs.csv-spec[groupByHaving]
249
249
----
250
250
251
251
Further more, one can use multiple aggregate expressions inside `HAVING` even ones that are not used in the output (`SELECT`):
252
252
253
- [" source"," sql",subs="attributes,callouts,macros" ]
253
+ [source, sql]
254
254
----
255
255
include-tagged::{sql-specs}/docs.csv-spec[groupByHavingMultiple]
256
256
----
@@ -264,14 +264,14 @@ As such, the query emits only a single row (as there is only a single group) and
264
264
265
265
In this example, `HAVING` matches:
266
266
267
- [" source"," sql",subs="attributes,callouts,macros" ]
267
+ [source, sql]
268
268
----
269
269
include-tagged::{sql-specs}/docs.csv-spec[groupByHavingImplicitMatch]
270
270
----
271
271
272
272
//However `HAVING` can also not match, in which case an empty result is returned:
273
273
//
274
- //[" source"," sql",subs="attributes,callouts,macros" ]
274
+ //[source, sql]
275
275
//----
276
276
//include-tagged::{sql-specs}/docs.csv-spec[groupByHavingImplicitNoMatch]
277
277
//----
@@ -300,7 +300,7 @@ IMPORTANT: When used along-side, `GROUP BY` expression can point _only_ to the c
300
300
301
301
For example, the following query sorts by an arbitrary input field (`page_count`):
302
302
303
- [" source"," sql",subs="attributes,callouts,macros" ]
303
+ [source, sql]
304
304
----
305
305
include-tagged::{sql-specs}/docs.csv-spec[orderByBasic]
306
306
----
@@ -317,15 +317,15 @@ combined using the same rules as {es}'s
317
317
318
318
To sort based on the `score`, use the special function `SCORE()`:
319
319
320
- [" source"," sql",subs="attributes,callouts,macros" ]
320
+ [source, sql]
321
321
----
322
322
include-tagged::{sql-specs}/docs.csv-spec[orderByScore]
323
323
----
324
324
325
325
Note that you can return `SCORE()` by using a full-text search predicate in the `WHERE` clause.
326
326
This is possible even if `SCORE()` is not used for sorting:
327
327
328
- [" source"," sql",subs="attributes,callouts,macros" ]
328
+ [source, sql]
329
329
----
330
330
include-tagged::{sql-specs}/docs.csv-spec[orderByScoreWithMatch]
331
331
----
@@ -353,7 +353,7 @@ ALL:: indicates there is no limit and thus all results are being returned.
353
353
354
354
To return
355
355
356
- [" source"," sql",subs="attributes,callouts,macros" ]
356
+ [source, sql]
357
357
----
358
358
include-tagged::{sql-specs}/docs.csv-spec[limitBasic]
359
359
----
0 commit comments