Skip to content

Commit 1a7d440

Browse files
Update readme.md
1 parent 0d8cdd5 commit 1a7d440

1 file changed

Lines changed: 11 additions & 9 deletions

File tree

Database Articles/Behavior Of Nulls/readme.md

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ The following truth tables display how the three-valued logic is applied.
7777
![Truth Tables Three Valued Logic](/Database%20Articles/Behavior%20Of%20Nulls/images/Truth_Tables_Three_Valued_Logic.png)
7878

7979

80-
A good example of the complexity is shown below in the following examples. [De Morgan's Law](https://en.wikipedia.org/wiki/De_Morgan%27s_laws) is also included below, as I show both versions of negation.
80+
A good example of the complexity is shown below. [De Morgan's Law](https://en.wikipedia.org/wiki/De_Morgan%27s_laws) is also included below, as I show both versions of negation.
8181

8282
```sql
8383
--TRUE OR UNKNOWN = TRUE
@@ -96,7 +96,7 @@ SELECT 3 WHERE NOT(1=2) AND NOT(NULL=1);
9696

9797
>:exclamation:      The standard setting for `ANSI_NULLS` is `ON`. In a future version of Microsoft SQL Server, `ANSI_NULLS` will always be `ON`, and any applications that explicitly set the option to `OFF` will produce an error. Avoid using this feature in new development work, and plan to modify applications that currently use this feature.
9898
99-
In Microsoft SQL Server, the `SET ANSI_NULLS` setting specifies the ISO compliant behavior of the equality (=) and inequality (<>) comparison operators. The following table shows how the `ANSI_NULLS` session setting affects the results of Boolean expressions using NULL markers.
99+
In Microsoft SQL Server, the `SET ANSI_NULLS` setting specifies the ISO-compliant behavior of the equality (=) and inequality (<>) comparison operators. The following table shows how the `ANSI_NULLS` session setting affects the results of Boolean expressions using NULL markers.
100100

101101
| Boolean Expression | SET ANSI_NULLS ON | SET ANSI_NULLS OFF |
102102
|------------------------|-------------------|--------------------|
@@ -219,7 +219,7 @@ The standard ANSI:SQL joins are `INNER`, `LEFT OUTER JOIN`, `RIGHT OUTER JOIN`,
219219
---------------------------------------------------------
220220
**INNER JOIN**
221221

222-
NULL markers are neither equal to nor not equal to each other. They are treated as **UNKNOWN**. This is best demonstrated by the below `INNER JOIN` statement, where NULL markers are absent in the result set. Note here we are looking for both equality and inequality in the `Fruit` column.
222+
NULL markers are neither equal to nor not equal to each other. They are treated as **UNKNOWN**. This is best demonstrated by the below `INNER JOIN` statement, where NULL markers are absent in the result set. Note that we are looking for both equality and inequality in the `Fruit` column.
223223

224224
```sql
225225
SELECT a.ID,
@@ -248,7 +248,7 @@ FROM ##TableA a INNER JOIN
248248
---------------------------------------------------
249249
**FULL OUTER JOIN**
250250

251-
The `FULL OUTER JOIN` will give an illusion that it matches the NULL markers, but looking closely at the number of NULL markers returned vs. the number of NULL markers in our sample data, we can determine this is indeed not true. Also, the below query demonstrates the `ORDER BY` sorts NULL markers in ascending order.
251+
The `FULL OUTER JOIN` will give an illusion that it matches the NULL markers, but looking closely at the number of NULL markers returned vs. the number of NULL markers in our sample data, we can determine this is indeed not true. Also, the query below demonstrates the `ORDER BY` sorting NULL markers in ascending order.
252252

253253
```sql
254254
SELECT a.ID,
@@ -310,7 +310,7 @@ WHERE a.Fruit IS DISTINCT FROM b.Fruit;
310310
## Semi and Anti Joins
311311
🔵&nbsp;&nbsp;&nbsp;[Table Of Contents](#table-of-contents)
312312

313-
Semi-joins and anti-joins are two closely related join methods. The semi-join and anti-join are types of joins between two tables where rows from the outer query are returned based on the presence or absence of a matching row in the joined table.
313+
Semi-joins and anti-joins are two closely related join methods. Semi-joins and anti-joins are types of joins between two tables where rows from the outer query are returned based on the presence or absence of a matching row in the joined table.
314314

315315
Anti-joins use the `NOT IN` or `NOT EXISTS` operators. Semi-joins use the `IN` or `EXISTS` operators.
316316

@@ -330,7 +330,7 @@ Also, each of these joins can be used as a correlated subquery. Using `EXISTS`
330330
--------------------------------------------------------
331331
**NOT IN**
332332

333-
This statement returns an empty dataset as the anti-join contains a NULL marker. Note that we are passing a set of parameters and not an SQL statement to the `NOT IN` clause.
333+
This statement returns an empty dataset as the anti-join contains a NULL marker. Note that we are passing a set of parameters, not an SQL statement, to the `NOT IN` clause.
334334

335335
```sql
336336
SELECT 1 AS RowNumber,
@@ -689,7 +689,9 @@ ORDER BY Fruit, RowNumber;
689689

690690
---------------------------------------------------------
691691

692-
The following two SQL statements return the same results when using SUM, COUNT, AVG, MIN, MAX, etc.
692+
The following two SQL statements return the same results when using `SUM`, `COUNT`, `AVG`, `MIN`, `MAX`, etc. For this example, we will use the `SUM` function.
693+
694+
When you do not specify an `ORDER BY` clause with a `SUM` windowing function, a total by the partitioning column is created. Using `SELECT NULL` in the `ORDER BY` produces the same results.
693695

694696
```sql
695697
SELECT *,
@@ -810,7 +812,7 @@ Multiple NULL markers can be inserted into the child column that has a foreign k
810812

811813
In Microsoft SQL Server, a `FOREIGN KEY` constraint must be linked to a column with either a `PRIMARY KEY` constraint or a `UNIQUE` constraint defined on the column. A `PRIMARY KEY` constraint does not allow NULL markers, but a `UNIQUE` constraint allows one NULL marker.
812814

813-
In the following example, we show that inserting multiple NULL markers into the Child is possible.ParentID column. This reflects the unfortunate reality that a child may be orphaned and, therefore, not have an associated parent.
815+
The following example shows that inserting multiple NULL markers into the Child is possible.ParentID column. This reflects the unfortunate reality that a child may be orphaned and, therefore, not have an associated parent.
814816

815817
Referential integrity cannot be created on temporary tables; for this example, we create two tables, `Parent` and `Child`.
816818

@@ -888,7 +890,7 @@ When creating a table with a non-NULLable computed column, you must create the c
888890
889891
From this error message, we can see there are several rules we need to follow on computed columns if we want to add `UNIQUE`, `PRIMARY KEY`, `FOREIGN KEY`, `CHECK`, and `NOT NULL` constraints.
890892

891-
Here, we add a `NOT NULL` constraint to a `PERSISTED` computed column and add a `PRIMARY KEY` to the column.
893+
Here, we add a `NOT NULL` constraint to a `PERSISTED` computed column and then run an 'ALTER TABLE' to create a `PRIMARY KEY` on the column.
892894

893895
```sql
894896
DROP TABLE IF EXISTS MyComputed;

0 commit comments

Comments
 (0)