You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/tutorials/sql_styleguide/index.md
+7-6Lines changed: 7 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -22,15 +22,15 @@ SQL is a standard language for storing, manipulating and retrieving data in data
22
22
**/
23
23
24
24
SELECT w.WRNG_JAR AS jaar
25
-
, w.WRNG_UTM1_CDE AS UTM1
25
+
, w.WRNG_UTM1_CDE AS utm1
26
26
, s.SPEC_NAM_WET AS wetenschappelijke_naam
27
27
, s.SPEC_NAM_NED AS nederlandse_naam
28
28
, t.TOPO_DES AS locatie
29
29
FROM tblWaarneming w
30
30
INNER JOIN tblWaarnemingMeting wm ON w.WRNG_ID = wm.WRME_WRNG_ID
31
31
INNER JOIN tblSoort s ON wm.WRME_SPEC_CDE = s.SPEC_CDE
32
32
LEFT JOIN tblToponiem t on t.TOPO_ID = w.WRNG_TOPO_ID --toponiemen werden niet altijd ingevuld
33
-
WHERE 1=1
33
+
WHERE 1 = 1
34
34
AND w.WRNG_UTM1_CDE IS NOT NULL
35
35
AND w.WRNG_JAR > 2010
36
36
GROUP BY w.WRNG_JAR
@@ -44,14 +44,15 @@ SQL is a standard language for storing, manipulating and retrieving data in data
44
44
45
45
* SQL-keywords (SELECT, FROM, JOIN, WHERE, GROUP BY, ...) are written in capitals
46
46
* Table names and field names are capitalized as they are defined in the database
47
-
* Use short and meaningfull aliases and write them in lowercase
47
+
* Use short and meaningful aliases and write them in lowercase
48
48
* Use a new line for each field in the SELECT-statement and each argument in the WHERE and GROUP BY clause
49
49
* Put the comma in front of the line in SELECT and GROUP BY statements
50
50
* Indent each field in the SELECT-statement and each argument in the WHERE and GROUP BY clause
51
51
* When multiple arguments are used in the WHERE clause, AND/OR keywords are always placed at the front
52
52
* Use full INNER JOIN statements
53
53
* JOINS should be indented
54
54
* Subqueries should be indented and properly named
55
+
* Put whitespaces around relational operators (= > ...)
55
56
* Document your scripts
56
57
57
58
@@ -108,7 +109,7 @@ SQL is a standard language for storing, manipulating and retrieving data in data
108
109
WHERE P.age > 50
109
110
```
110
111
111
-
* Table aliases are short and meaningfull in the context of the query
112
+
* Table aliases are short and meaningful in the context of the query
112
113
113
114
```
114
115
--Good
@@ -415,7 +416,7 @@ SQL is a standard language for storing, manipulating and retrieving data in data
415
416
416
417
* Use TOP 10 (or LIMIT 10 in Postgres) when designing queries with a large resultset (taking a long time to run). It saves a lot of time in the design stage.
417
418
418
-
* Use 1=1 as the first line of the WHERE clause. This allows you to easily turn on and off all restrictions while designing your query. Beware of OR: where 1=1 OR age>50 doesn’t mean that everybody is +50.
419
+
* Use 1 = 1 as the first line of the WHERE clause. This allows you to easily turn on and off all restrictions while designing your query. Beware of OR: where 1 = 1 OR age > 50 doesn’t mean that everybody is +50.
419
420
420
421
421
422
```
@@ -426,7 +427,7 @@ SQL is a standard language for storing, manipulating and retrieving data in data
0 commit comments