@@ -32,12 +32,10 @@ license_url: "https://creativecommons.org/licenses/by-nc-sa/4.0/"
3232Be careful of the overuse of functions in OLTP use cases where it may be better to add a column such as a virtual column that contains calculations already rendered
3333
3434``` sql
35- SELECT CONCAT(name_first, SPACE(1 ), name_last) AS ' Name' ,
36-
37- (DAYOFYEAR(birthdate) - DAYOFYEAR(CURDATE())) / 12 AS ' Months to Birthday'
38-
35+ SELECT
36+ CONCAT(name_first, SPACE(1 ), name_last) AS ' Name' ,
37+ (DAYOFYEAR(birthdate) - DAYOFYEAR(CURDATE())) / 12 AS ' Months to Birthday'
3938FROM clients
40-
4139LIMIT 1 ;
4240```
4341
@@ -53,7 +51,9 @@ Columns with Operators can be Specified to Filter Results
5351SELECT Name, Population
5452FROM City
5553WHERE Population > 1000000 ;
54+ ```
5655
56+ ``` shell
5757+-------------+------------+
5858| Name | Population |
5959+-------------+------------+
@@ -95,7 +95,7 @@ WHERE CountryCode = 'FIN'
9595LIMIT 2 , 3 ;
9696```
9797
98- ``` sql
98+ ``` shell
9999+-------------------+-----------+
100100| Name | District |
101101+-------------------+-----------+
@@ -109,25 +109,31 @@ LIMIT 2, 3;
109109
110110Data can be Ordered and Broken into Blocks
111111
112- ` SELECT cols `
113- ` FROM table `
114- ` WHERE clause `
115- ` ORDER BY col `
116- ` LIMIT offset, count; `
112+ ``` sql
113+ SELECT cols
114+ FROM table
115+ WHERE clause
116+ ORDER BY col
117+ LIMIT offset, count;
118+ ```
117119
118120Basic Syntax Example for ` SELECT ` Statement with ` ORDER BY ` Clause
119121
120- ` SELECT Name, Population `
121- ` FROM City `
122- ` WHERE Population > 1000000 `
123- ` ORDER BY Population `
124- ` LIMIT 0, 3; `
122+ ``` sql
123+ SELECT Name, Population
124+ FROM City
125+ WHERE Population > 1000000
126+ ORDER BY Population
127+ LIMIT 0 , 3 ;
128+ ```
125129
130+ ``` shell
126131| Name | Population |
127132| ---------| ------------|
128133| Zapopan | 1,012,563 |
129134| Napoli | 1,002,079 |
130135| Perm | 1,070,162 |
136+ ```
131137
132138### Ascending and descending order
133139
@@ -141,8 +147,9 @@ No descending indexes however B+ Tree indexes can be used to optimize sort or ra
141147SELECT Name, District FROM City
142148WHERE CountryCode = ' FIN'
143149ORDER BY District DESC , Name ASC ;
150+ ```
144151
145-
152+ ``` shell
146153| Name | District |
147154| ----------------| ------------------|
148155| Turku [Åbo] | Varsinais-Suomi |
@@ -162,7 +169,9 @@ Useful with Aggregate Functions to Create Sub-Groups
162169SELECT Continent, SUM (Population)
163170FROM Country
164171GROUP BY Continent;
172+ ```
165173
174+ ``` shell
166175+---------------+------------------+
167176| Continent | SUM(Population) |
168177+---------------+------------------+
@@ -745,4 +754,4 @@ Or using subqueries used for accessing hierarchical data
745754- 5-6 Using Common Table Expressions
746755- 5-7 Using Window Functions
747756- 5-8 Rolling Back a Transaction
748- - 5-9 Observing a Deadlock
757+ - 5-9 Observing a Deadlock
0 commit comments