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: README.md
+23-1Lines changed: 23 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -17,6 +17,7 @@
17
17
11.[Joining Tables](#Joining-Tables)
18
18
12.[Advanced Joins](#Advanced-Joins)
19
19
13.[Combining Queries](#Combining-Queries)
20
+
14.[Case Statement](#Case-Statement)
20
21
21
22
### Resources:
22
23
@@ -692,7 +693,7 @@ WHERE p.SupplierID = s.SupplierID
692
693
693
694
#### Example:
694
695
695
-
- The below SQL Statement returns all countries of the Suppliers and Customers within a single query result set.
696
+
- The below SQL Statement returns all unique countries from the Suppliers and Customers table within a single query result set.
696
697
697
698
```sql
698
699
SELECT Country FROM Suppliers
@@ -715,4 +716,25 @@ SELECT Country FROM Customers
715
716
716
717
---
717
718
719
+
## Case Statement
720
+
721
+
- The CASE statement goes through conditions and returns a value when the first condition is met (like an IF-THEN-ELSE statement)
722
+
- Once a condition is true, it will stop reading and return the result.
723
+
- If no conditions are true, it returns the value in the ELSE clause.
724
+
725
+
#### Example:
726
+
727
+
- The below SQL statement returns a value of YES if the order quantity is greater than 40. If not, a value of NO is returned under the calculated field, QuantityOver40
728
+
729
+
```sql
730
+
SELECT OrderID,
731
+
CASE
732
+
WHEN Quantity >40 THEN "YES"
733
+
ELSE "NO"
734
+
END as QuantityOver40
735
+
FROM OrderDetails
736
+
```
737
+
738
+
---
739
+
718
740
> You have reached the end of the SQL quick start guide!
0 commit comments