@@ -36,7 +36,7 @@ The general execution of `SELECT` is as follows:
3636
3737As with a table, every output column of a `SELECT` has a name which can be either specified per column through the `AS` keyword :
3838
39- [" source"," sql",subs="attributes,callouts,macros" ]
39+ [source, sql]
4040----
4141include-tagged::{sql-specs}/docs.csv-spec[selectColumnAlias]
4242----
@@ -46,14 +46,14 @@ which is why it is recommended to specify it.
4646
4747assigned by {es-sql} if no name is given:
4848
49- [" source"," sql",subs="attributes,callouts,macros" ]
49+ [source, sql]
5050----
5151include-tagged::{sql-specs}/docs.csv-spec[selectInline]
5252----
5353
5454or if it's a simple column reference, use its name as the column name:
5555
56- [" source"," sql",subs="attributes,callouts,macros" ]
56+ [source, sql]
5757----
5858include-tagged::{sql-specs}/docs.csv-spec[selectColumn]
5959----
@@ -63,7 +63,7 @@ include-tagged::{sql-specs}/docs.csv-spec[selectColumn]
6363
6464To select all the columns in the source, one can use `*`:
6565
66- [" source"," sql",subs="attributes,callouts,macros" ]
66+ [source, sql]
6767----
6868include-tagged::{sql-specs}/docs.csv-spec[wildcardWithOrder]
6969----
@@ -90,22 +90,22 @@ Represents the name (optionally qualified) of an existing table, either a concre
9090
9191If the table name contains special SQL characters (such as `.`,`-`,etc...) use double quotes to escape them:
9292
93- [" source"," sql",subs="attributes,callouts,macros" ]
93+ [source, sql]
9494----
9595include-tagged::{sql-specs}/docs.csv-spec[fromTableQuoted]
9696----
9797
9898The 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**.
9999
100- [" source"," sql",subs="attributes,callouts,macros" ]
100+ [source, sql]
101101----
102102include-tagged::{sql-specs}/docs.csv-spec[fromTablePatternQuoted]
103103----
104104
105105`alias`::
106106A 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.
107107
108- [" source"," sql",subs="attributes,callouts,macros" ]
108+ [source, sql]
109109----
110110include-tagged::{sql-specs}/docs.csv-spec[fromTableAlias]
111111----
@@ -127,7 +127,7 @@ where:
127127
128128Represents an expression that evaluates to a `boolean`. Only the rows that match the condition (to `true`) are returned.
129129
130- [" source"," sql",subs="attributes,callouts,macros" ]
130+ [source, sql]
131131----
132132include-tagged::{sql-specs}/docs.csv-spec[basicWhere]
133133----
@@ -151,34 +151,34 @@ Represents an expression on which rows are being grouped _on_. It can be a colum
151151
152152A common, group by column name:
153153
154- [" source"," sql",subs="attributes,callouts,macros" ]
154+ [source, sql]
155155----
156156include-tagged::{sql-specs}/docs.csv-spec[groupByColumn]
157157----
158158
159159Grouping by output ordinal:
160160
161- [" source"," sql",subs="attributes,callouts,macros" ]
161+ [source, sql]
162162----
163163include-tagged::{sql-specs}/docs.csv-spec[groupByOrdinal]
164164----
165165
166166Grouping by alias:
167167
168- [" source"," sql",subs="attributes,callouts,macros" ]
168+ [source, sql]
169169----
170170include-tagged::{sql-specs}/docs.csv-spec[groupByAlias]
171171----
172172
173173And grouping by column expression (typically used along-side an alias):
174174
175- [" source"," sql",subs="attributes,callouts,macros" ]
175+ [source, sql]
176176----
177177include-tagged::{sql-specs}/docs.csv-spec[groupByExpression]
178178----
179179
180180Or a mixture of the above:
181- [" source"," sql",subs="attributes,callouts,macros" ]
181+ [source, sql]
182182----
183183include-tagged::{sql-specs}/docs.csv-spec[groupByMulti]
184184----
@@ -188,21 +188,21 @@ When a `GROUP BY` clause is used in a `SELECT`, _all_ output expressions must be
188188
189189To wit:
190190
191- [" source"," sql",subs="attributes,callouts,macros" ]
191+ [source, sql]
192192----
193193include-tagged::{sql-specs}/docs.csv-spec[groupByAndAgg]
194194----
195195
196196Expressions over aggregates used in output:
197197
198- [" source"," sql",subs="attributes,callouts,macros" ]
198+ [source, sql]
199199----
200200include-tagged::{sql-specs}/docs.csv-spec[groupByAndAggExpression]
201201----
202202
203203Multiple aggregates used:
204204
205- [" source"," sql",subs="attributes,callouts,macros" ]
205+ [source, sql]
206206----
207207include-tagged::{sql-specs}/docs.csv-spec[groupByAndMultipleAggs]
208208----
@@ -216,14 +216,14 @@ As such, the query emits only a single row (as there is only a single group).
216216
217217A common example is counting the number of records:
218218
219- [" source"," sql",subs="attributes,callouts,macros" ]
219+ [source, sql]
220220----
221221include-tagged::{sql-specs}/docs.csv-spec[groupByImplicitCount]
222222----
223223
224224Of course, multiple aggregations can be applied:
225225
226- [" source"," sql",subs="attributes,callouts,macros" ]
226+ [source, sql]
227227----
228228include-tagged::{sql-specs}/docs.csv-spec[groupByImplicitMultipleAggs]
229229----
@@ -250,14 +250,14 @@ Both `WHERE` and `HAVING` are used for filtering however there are several signi
250250. `WHERE` works on individual *rows*, `HAVING` works on the *groups* created by ``GROUP BY``
251251. `WHERE` is evaluated *before* grouping, `HAVING` is evaluated *after* grouping
252252
253- [" source"," sql",subs="attributes,callouts,macros" ]
253+ [source, sql]
254254----
255255include-tagged::{sql-specs}/docs.csv-spec[groupByHaving]
256256----
257257
258258Further more, one can use multiple aggregate expressions inside `HAVING` even ones that are not used in the output (`SELECT`):
259259
260- [" source"," sql",subs="attributes,callouts,macros" ]
260+ [source, sql]
261261----
262262include-tagged::{sql-specs}/docs.csv-spec[groupByHavingMultiple]
263263----
@@ -271,14 +271,14 @@ As such, the query emits only a single row (as there is only a single group) and
271271
272272In this example, `HAVING` matches:
273273
274- [" source"," sql",subs="attributes,callouts,macros" ]
274+ [source, sql]
275275----
276276include-tagged::{sql-specs}/docs.csv-spec[groupByHavingImplicitMatch]
277277----
278278
279279//However `HAVING` can also not match, in which case an empty result is returned:
280280//
281- //[" source"," sql",subs="attributes,callouts,macros" ]
281+ //[source, sql]
282282//----
283283//include-tagged::{sql-specs}/docs.csv-spec[groupByHavingImplicitNoMatch]
284284//----
@@ -307,7 +307,7 @@ IMPORTANT: When used along-side, `GROUP BY` expression can point _only_ to the c
307307
308308For example, the following query sorts by an arbitrary input field (`page_count`):
309309
310- [" source"," sql",subs="attributes,callouts,macros" ]
310+ [source, sql]
311311----
312312include-tagged::{sql-specs}/docs.csv-spec[orderByBasic]
313313----
@@ -324,15 +324,15 @@ combined using the same rules as {es}'s
324324
325325To sort based on the `score`, use the special function `SCORE()`:
326326
327- [" source"," sql",subs="attributes,callouts,macros" ]
327+ [source, sql]
328328----
329329include-tagged::{sql-specs}/docs.csv-spec[orderByScore]
330330----
331331
332332Note that you can return `SCORE()` by using a full-text search predicate in the `WHERE` clause.
333333This is possible even if `SCORE()` is not used for sorting:
334334
335- [" source"," sql",subs="attributes,callouts,macros" ]
335+ [source, sql]
336336----
337337include-tagged::{sql-specs}/docs.csv-spec[orderByScoreWithMatch]
338338----
@@ -360,7 +360,7 @@ ALL:: indicates there is no limit and thus all results are being returned.
360360
361361To return
362362
363- [" source"," sql",subs="attributes,callouts,macros" ]
363+ [source, sql]
364364----
365365include-tagged::{sql-specs}/docs.csv-spec[limitBasic]
366366----
0 commit comments