From c9f7959a88697bf558dc70379c625dd785818c6e Mon Sep 17 00:00:00 2001 From: Nicole Barnhouse <104863678+nbarnhouse@users.noreply.github.com> Date: Mon, 3 Jun 2024 08:44:36 -0500 Subject: [PATCH 01/17] added shell for concept --- .../operator-invocations.md | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 content/postgresql/concepts/operator-invocations/operator-invocations.md diff --git a/content/postgresql/concepts/operator-invocations/operator-invocations.md b/content/postgresql/concepts/operator-invocations/operator-invocations.md new file mode 100644 index 00000000000..3ad1a587341 --- /dev/null +++ b/content/postgresql/concepts/operator-invocations/operator-invocations.md @@ -0,0 +1,22 @@ +--- +Title: 'Operator Invocations' +Description: '' +Subjects: + - 'Computer Science' + - 'Data Science' +Tags: + - 'Data' + - 'Operators' + - 'PostgreSQL' +CatalogContent: + - 'learn-sql' + - 'paths/data-science-foundations' +--- + +In PostgreSQL, **operator invocations** are + +## Syntax + +## Example 1 + + From 53c085b95a7d5adb7bb0fd1fbe69431dc91e8e10 Mon Sep 17 00:00:00 2001 From: Nicole Barnhouse <104863678+nbarnhouse@users.noreply.github.com> Date: Tue, 11 Jun 2024 21:40:28 -0500 Subject: [PATCH 02/17] completed first draft of operator-invocations --- .../operator-invocations.md | 78 ++++++++++++++++++- 1 file changed, 77 insertions(+), 1 deletion(-) diff --git a/content/postgresql/concepts/operator-invocations/operator-invocations.md b/content/postgresql/concepts/operator-invocations/operator-invocations.md index 3ad1a587341..90188d0ff8f 100644 --- a/content/postgresql/concepts/operator-invocations/operator-invocations.md +++ b/content/postgresql/concepts/operator-invocations/operator-invocations.md @@ -13,10 +13,86 @@ CatalogContent: - 'paths/data-science-foundations' --- -In PostgreSQL, **operator invocations** are +In PostgreSQL, **operator invocations** allow operations to be excuted on data in one or multiple tables in a database. They can be used to but are not limited to calculations, comparisons, joining and filtering. + +Note: These are common operators, but there are many others avaiable to use. ## Syntax +### Comparison Operators + +```pseudo +--Equal +SELECT * from table_name +WHERE column1 = 'North'; + +--Not Equal +SELECT * from table_name +WHERE column1 = column2; + +-- Greater Than (or Equal To) +SELECT * from table_name +WHERE column1 > 10; + +-- Less Than (or Equal To) +SELECT * from table_name +WHERE column1 < 1000; +``` + +### Logical Operators + +```pseudo +-- And +SELECT * from table_name +WHERE column1 >= 10 AND column1 <= 1000; + +-- Or +SELECT * from table_name +WHERE column1 = 'North' OR 'WEST'; + +-- Not +SELECT * from table_name +WHERE NOT column1 = 'SOUTH'; +``` + + ## Example 1 +Here's an example of operator invocations on data in the table `animals`. + +| `id` | `name` | `species` | `gender` | `age` | +| ---- | -------- | ----------- | ---------- | ------ | +| 01 | Niko | monkey | female | 3 | +| 02 | Frank | giraffe | male | 4 | +| 03 | Lyn | lion | female | 6 | +| 04 | Tom | elephant | male | 7 | + + +```sql +SELECT * from animals +WHERE gender = 'female' AND age >= 4; +``` + +Output: + +| `id` | `name` | `species` | `gender` | `age` | +| ---- | -------- | ----------- | ---------- | ------ | +| 03 | Lyn | lion | female | 6 | + + +## Example 2 + +Using that same table, here is another operator invocation example. + +```sql +SELECT * from animals +WHERE NOT species = 'lion'; +``` + +Output: +| `id` | `name` | `species` | `gender` | `age` | +| ---- | -------- | ----------- | ---------- | ------ | +| 01 | Niko | monkey | female | 3 | +| 02 | Frank | giraffe | male | 4 | +| 04 | Tom | elephant | male | 7 | \ No newline at end of file From 5de529242027d10ed57c1261f0224c3b34c6c9b4 Mon Sep 17 00:00:00 2001 From: Nicole Barnhouse <104863678+nbarnhouse@users.noreply.github.com> Date: Thu, 13 Jun 2024 06:26:18 -0500 Subject: [PATCH 03/17] added shell for file structure --- .../math-methods/terms/degrees/degrees.md | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 content/numpy/concepts/math-methods/terms/degrees/degrees.md diff --git a/content/numpy/concepts/math-methods/terms/degrees/degrees.md b/content/numpy/concepts/math-methods/terms/degrees/degrees.md new file mode 100644 index 00000000000..1cac2740b6d --- /dev/null +++ b/content/numpy/concepts/math-methods/terms/degrees/degrees.md @@ -0,0 +1,26 @@ +--- +Title: '.degrees()' +Description: 'Calculates the square root of each element in an array.' +Subjects: + - 'Computer Science' + - 'Data Science' +Tags: + - 'Arrays' + - 'Functions' + - 'NumPy' +CatalogContent: + - 'learn-python-3' + - 'paths/computer-science' +--- + +In NumPy, the **`.degrees()`** function + +## Syntax + + + +## Example + + +## Codebyte Example + From 5e4b65e33df8828abdcc2738989bd3fd53789b23 Mon Sep 17 00:00:00 2001 From: Nicole Barnhouse <104863678+nbarnhouse@users.noreply.github.com> Date: Sat, 15 Jun 2024 07:13:31 -0500 Subject: [PATCH 04/17] completed description and syntax, working through examples now --- .../math-methods/terms/degrees/degrees.md | 55 ++++++++++++++++++- 1 file changed, 52 insertions(+), 3 deletions(-) diff --git a/content/numpy/concepts/math-methods/terms/degrees/degrees.md b/content/numpy/concepts/math-methods/terms/degrees/degrees.md index 1cac2740b6d..a5be1701de7 100644 --- a/content/numpy/concepts/math-methods/terms/degrees/degrees.md +++ b/content/numpy/concepts/math-methods/terms/degrees/degrees.md @@ -1,6 +1,6 @@ --- Title: '.degrees()' -Description: 'Calculates the square root of each element in an array.' +Description: 'Converts radians to degrees.' Subjects: - 'Computer Science' - 'Data Science' @@ -13,14 +13,63 @@ CatalogContent: - 'paths/computer-science' --- -In NumPy, the **`.degrees()`** function +In NumPy, the **`.degrees()`** function converts angle radians to degrees. ## Syntax +```pseudo +numpy.degrees(x) +``` +- `x`: The number or array of numbers in radians that must be converted. + +## Example 1 + +```py +# Importing the 'numpy' library as 'np' +import numpy as np + +# Convert a single number from radians to desgrees +result = + +print(result) +``` + +The output of the above code is shown below: + +```shell +[3] +``` + + +## Example 2 + +```py +# Importing the 'numpy' library as 'np' +import numpy as np + +# Convert an array of numbers from radians to degrees +result = + +print(result) +``` + +The output of the above code is shown below: + +```shell +[3, 5, 6] +``` -## Example ## Codebyte Example +In this codebyte example, the `.degree()` method converts + +```codebyte/python +import numpy as np + +result = + +print(result) +``` From 7783c09a1461b4b8b5de27160c7a83c99cbc111c Mon Sep 17 00:00:00 2001 From: Nicole Barnhouse <104863678+nbarnhouse@users.noreply.github.com> Date: Mon, 17 Jun 2024 11:53:31 -0500 Subject: [PATCH 05/17] completed initial write up of numpy.degrees --- .../math-methods/terms/degrees/degrees.md | 22 ++++++++++--------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/content/numpy/concepts/math-methods/terms/degrees/degrees.md b/content/numpy/concepts/math-methods/terms/degrees/degrees.md index a5be1701de7..204348debc9 100644 --- a/content/numpy/concepts/math-methods/terms/degrees/degrees.md +++ b/content/numpy/concepts/math-methods/terms/degrees/degrees.md @@ -13,12 +13,14 @@ CatalogContent: - 'paths/computer-science' --- -In NumPy, the **`.degrees()`** function converts angle radians to degrees. +In NumPy, the **`.degrees()`** function converts an angle measure from radians to degrees. ## Syntax ```pseudo numpy.degrees(x) + +numpy.degrees([x, x, x]) ``` - `x`: The number or array of numbers in radians that must be converted. @@ -29,16 +31,16 @@ numpy.degrees(x) # Importing the 'numpy' library as 'np' import numpy as np -# Convert a single number from radians to desgrees -result = - +# Convert a single number from radians to degrees +radNum = 4 +result = np.degrees(radNum) print(result) ``` The output of the above code is shown below: ```shell -[3] +229.1831180523293 ``` @@ -49,15 +51,15 @@ The output of the above code is shown below: import numpy as np # Convert an array of numbers from radians to degrees -result = - +radArray = [ 2, 4, 5, 8] +result = np.degrees(radArray) print(result) ``` The output of the above code is shown below: ```shell -[3, 5, 6] +[114.59155903 229.18311805 286.47889757 458.3662361 ] ``` @@ -69,7 +71,7 @@ In this codebyte example, the `.degree()` method converts ```codebyte/python import numpy as np -result = - +radArray = [ 1, 32, 100] +result = np.degrees(radArray) print(result) ``` From 88ef1471dd4e952f305ff5be96fd504997a1e995 Mon Sep 17 00:00:00 2001 From: Nicole Barnhouse <104863678+nbarnhouse@users.noreply.github.com> Date: Mon, 17 Jun 2024 12:07:19 -0500 Subject: [PATCH 06/17] corrected missing description --- .../concepts/operator-invocations/operator-invocations.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/postgresql/concepts/operator-invocations/operator-invocations.md b/content/postgresql/concepts/operator-invocations/operator-invocations.md index 90188d0ff8f..5bfcb43b25c 100644 --- a/content/postgresql/concepts/operator-invocations/operator-invocations.md +++ b/content/postgresql/concepts/operator-invocations/operator-invocations.md @@ -1,6 +1,6 @@ --- Title: 'Operator Invocations' -Description: '' +Description: 'The execution of operations on data' Subjects: - 'Computer Science' - 'Data Science' From 2c9017f67ec3c4c2ac51734949bfb7fa06983b55 Mon Sep 17 00:00:00 2001 From: Nicole Barnhouse <104863678+nbarnhouse@users.noreply.github.com> Date: Mon, 17 Jun 2024 12:15:08 -0500 Subject: [PATCH 07/17] corrected md file with missing description --- .../concepts/operator-invocations/operator-invocations.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/postgresql/concepts/operator-invocations/operator-invocations.md b/content/postgresql/concepts/operator-invocations/operator-invocations.md index 5bfcb43b25c..d87e9a8ce66 100644 --- a/content/postgresql/concepts/operator-invocations/operator-invocations.md +++ b/content/postgresql/concepts/operator-invocations/operator-invocations.md @@ -1,6 +1,6 @@ --- Title: 'Operator Invocations' -Description: 'The execution of operations on data' +Description: 'The execution of operations on data.' Subjects: - 'Computer Science' - 'Data Science' From 8ae7e64b7b31b8da7f825f8342d7c38656781b29 Mon Sep 17 00:00:00 2001 From: Nicole Barnhouse <104863678+nbarnhouse@users.noreply.github.com> Date: Mon, 17 Jun 2024 12:20:40 -0500 Subject: [PATCH 08/17] removing file added in error --- .../math-methods/terms/degrees/degrees.md | 77 ------------------- 1 file changed, 77 deletions(-) delete mode 100644 content/numpy/concepts/math-methods/terms/degrees/degrees.md diff --git a/content/numpy/concepts/math-methods/terms/degrees/degrees.md b/content/numpy/concepts/math-methods/terms/degrees/degrees.md deleted file mode 100644 index 204348debc9..00000000000 --- a/content/numpy/concepts/math-methods/terms/degrees/degrees.md +++ /dev/null @@ -1,77 +0,0 @@ ---- -Title: '.degrees()' -Description: 'Converts radians to degrees.' -Subjects: - - 'Computer Science' - - 'Data Science' -Tags: - - 'Arrays' - - 'Functions' - - 'NumPy' -CatalogContent: - - 'learn-python-3' - - 'paths/computer-science' ---- - -In NumPy, the **`.degrees()`** function converts an angle measure from radians to degrees. - -## Syntax - -```pseudo -numpy.degrees(x) - -numpy.degrees([x, x, x]) -``` - -- `x`: The number or array of numbers in radians that must be converted. - -## Example 1 - -```py -# Importing the 'numpy' library as 'np' -import numpy as np - -# Convert a single number from radians to degrees -radNum = 4 -result = np.degrees(radNum) -print(result) -``` - -The output of the above code is shown below: - -```shell -229.1831180523293 -``` - - -## Example 2 - -```py -# Importing the 'numpy' library as 'np' -import numpy as np - -# Convert an array of numbers from radians to degrees -radArray = [ 2, 4, 5, 8] -result = np.degrees(radArray) -print(result) -``` - -The output of the above code is shown below: - -```shell -[114.59155903 229.18311805 286.47889757 458.3662361 ] -``` - - - -## Codebyte Example - -In this codebyte example, the `.degree()` method converts - -```codebyte/python -import numpy as np - -radArray = [ 1, 32, 100] -result = np.degrees(radArray) -print(result) -``` From a48af586a6b8777bc9c3e224718b3106ed6609a9 Mon Sep 17 00:00:00 2001 From: Nicole Barnhouse <104863678+nbarnhouse@users.noreply.github.com> Date: Thu, 27 Jun 2024 12:17:22 -0500 Subject: [PATCH 09/17] Update content/postgresql/concepts/operator-invocations/operator-invocations.md Co-authored-by: shantanu <56212958+cigar-galaxy82@users.noreply.github.com> --- .../concepts/operator-invocations/operator-invocations.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/postgresql/concepts/operator-invocations/operator-invocations.md b/content/postgresql/concepts/operator-invocations/operator-invocations.md index d87e9a8ce66..9646d3ed860 100644 --- a/content/postgresql/concepts/operator-invocations/operator-invocations.md +++ b/content/postgresql/concepts/operator-invocations/operator-invocations.md @@ -15,7 +15,7 @@ CatalogContent: In PostgreSQL, **operator invocations** allow operations to be excuted on data in one or multiple tables in a database. They can be used to but are not limited to calculations, comparisons, joining and filtering. -Note: These are common operators, but there are many others avaiable to use. +> **Note:** These are common operators, but many others are available to use. ## Syntax From 3ea051a79d83603f25350e2b8b2106e9243c3aef Mon Sep 17 00:00:00 2001 From: Nicole Barnhouse <104863678+nbarnhouse@users.noreply.github.com> Date: Thu, 27 Jun 2024 12:17:30 -0500 Subject: [PATCH 10/17] Update content/postgresql/concepts/operator-invocations/operator-invocations.md Co-authored-by: shantanu <56212958+cigar-galaxy82@users.noreply.github.com> --- .../concepts/operator-invocations/operator-invocations.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/postgresql/concepts/operator-invocations/operator-invocations.md b/content/postgresql/concepts/operator-invocations/operator-invocations.md index 9646d3ed860..5517ea5b73b 100644 --- a/content/postgresql/concepts/operator-invocations/operator-invocations.md +++ b/content/postgresql/concepts/operator-invocations/operator-invocations.md @@ -13,7 +13,7 @@ CatalogContent: - 'paths/data-science-foundations' --- -In PostgreSQL, **operator invocations** allow operations to be excuted on data in one or multiple tables in a database. They can be used to but are not limited to calculations, comparisons, joining and filtering. +In PostgreSQL, **operator invocations** allow operations to be executed on data in one or multiple tables in a database. They can be used for calculations, comparisons, joining, filtering, etc. > **Note:** These are common operators, but many others are available to use. From 61e08bef05a969cb7afececeef5857fff26d0152 Mon Sep 17 00:00:00 2001 From: Nicole Barnhouse <104863678+nbarnhouse@users.noreply.github.com> Date: Thu, 27 Jun 2024 12:17:38 -0500 Subject: [PATCH 11/17] Update content/postgresql/concepts/operator-invocations/operator-invocations.md Co-authored-by: shantanu <56212958+cigar-galaxy82@users.noreply.github.com> --- .../concepts/operator-invocations/operator-invocations.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/postgresql/concepts/operator-invocations/operator-invocations.md b/content/postgresql/concepts/operator-invocations/operator-invocations.md index 5517ea5b73b..28f10676ec0 100644 --- a/content/postgresql/concepts/operator-invocations/operator-invocations.md +++ b/content/postgresql/concepts/operator-invocations/operator-invocations.md @@ -1,6 +1,6 @@ --- Title: 'Operator Invocations' -Description: 'The execution of operations on data.' +Description: 'Used to perform operations on the data using operators.' Subjects: - 'Computer Science' - 'Data Science' From 2ea31a5ba473014e0bea2852a0f9d8ae841f2c3f Mon Sep 17 00:00:00 2001 From: Nicole Barnhouse <104863678+nbarnhouse@users.noreply.github.com> Date: Thu, 27 Jun 2024 12:17:45 -0500 Subject: [PATCH 12/17] Update content/postgresql/concepts/operator-invocations/operator-invocations.md Co-authored-by: shantanu <56212958+cigar-galaxy82@users.noreply.github.com> --- .../concepts/operator-invocations/operator-invocations.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/content/postgresql/concepts/operator-invocations/operator-invocations.md b/content/postgresql/concepts/operator-invocations/operator-invocations.md index 28f10676ec0..4440e4f74f5 100644 --- a/content/postgresql/concepts/operator-invocations/operator-invocations.md +++ b/content/postgresql/concepts/operator-invocations/operator-invocations.md @@ -11,6 +11,8 @@ Tags: CatalogContent: - 'learn-sql' - 'paths/data-science-foundations' + - 'paths/analyze-data-with-sql' + - 'paths/design-databases-with-postgresql' --- In PostgreSQL, **operator invocations** allow operations to be executed on data in one or multiple tables in a database. They can be used for calculations, comparisons, joining, filtering, etc. From dff8c89d9d9e179a0cc29b7cab212db8d25c9bb5 Mon Sep 17 00:00:00 2001 From: Nicole Barnhouse <104863678+nbarnhouse@users.noreply.github.com> Date: Thu, 27 Jun 2024 12:17:57 -0500 Subject: [PATCH 13/17] Update content/postgresql/concepts/operator-invocations/operator-invocations.md Co-authored-by: shantanu <56212958+cigar-galaxy82@users.noreply.github.com> --- .../operator-invocations/operator-invocations.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/content/postgresql/concepts/operator-invocations/operator-invocations.md b/content/postgresql/concepts/operator-invocations/operator-invocations.md index 4440e4f74f5..6ca80db1fde 100644 --- a/content/postgresql/concepts/operator-invocations/operator-invocations.md +++ b/content/postgresql/concepts/operator-invocations/operator-invocations.md @@ -44,16 +44,16 @@ WHERE column1 < 1000; ### Logical Operators ```pseudo --- And -SELECT * from table_name +// AND +SELECT * FROM table_name WHERE column1 >= 10 AND column1 <= 1000; --- Or -SELECT * from table_name +// OR +SELECT * FROM table_name WHERE column1 = 'North' OR 'WEST'; --- Not -SELECT * from table_name +// NOT +SELECT * FROM table_name WHERE NOT column1 = 'SOUTH'; ``` From 23b2acdb4318191b15a85018fe3bdfc294c70b75 Mon Sep 17 00:00:00 2001 From: Nicole Barnhouse <104863678+nbarnhouse@users.noreply.github.com> Date: Thu, 27 Jun 2024 12:18:04 -0500 Subject: [PATCH 14/17] Update content/postgresql/concepts/operator-invocations/operator-invocations.md Co-authored-by: shantanu <56212958+cigar-galaxy82@users.noreply.github.com> --- .../operator-invocations.md | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/content/postgresql/concepts/operator-invocations/operator-invocations.md b/content/postgresql/concepts/operator-invocations/operator-invocations.md index 6ca80db1fde..4ab7a250b24 100644 --- a/content/postgresql/concepts/operator-invocations/operator-invocations.md +++ b/content/postgresql/concepts/operator-invocations/operator-invocations.md @@ -24,20 +24,20 @@ In PostgreSQL, **operator invocations** allow operations to be executed on data ### Comparison Operators ```pseudo ---Equal -SELECT * from table_name +// Equal to +SELECT * FROM table_name WHERE column1 = 'North'; ---Not Equal -SELECT * from table_name -WHERE column1 = column2; +// Not Equal to +SELECT * FROM table_name +WHERE column1 != column2; --- Greater Than (or Equal To) -SELECT * from table_name +// Greater than +SELECT * FROM table_name WHERE column1 > 10; --- Less Than (or Equal To) -SELECT * from table_name +// Less than +SELECT * FROM table_name WHERE column1 < 1000; ``` From ff28c5f9b86c6c5fded1f0002c9e76c7f14b8c79 Mon Sep 17 00:00:00 2001 From: Nicole Barnhouse <104863678+nbarnhouse@users.noreply.github.com> Date: Thu, 27 Jun 2024 12:18:13 -0500 Subject: [PATCH 15/17] Update content/postgresql/concepts/operator-invocations/operator-invocations.md Co-authored-by: shantanu <56212958+cigar-galaxy82@users.noreply.github.com> --- .../concepts/operator-invocations/operator-invocations.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/content/postgresql/concepts/operator-invocations/operator-invocations.md b/content/postgresql/concepts/operator-invocations/operator-invocations.md index 4ab7a250b24..29d4c67aea4 100644 --- a/content/postgresql/concepts/operator-invocations/operator-invocations.md +++ b/content/postgresql/concepts/operator-invocations/operator-invocations.md @@ -87,8 +87,7 @@ Output: Using that same table, here is another operator invocation example. ```sql -SELECT * from animals -WHERE NOT species = 'lion'; +SELECT * FROM animals WHERE NOT species = 'lion'; ``` Output: From d714e37f98ff3055ef1d9155114f2fec1cae4f89 Mon Sep 17 00:00:00 2001 From: Nicole Barnhouse <104863678+nbarnhouse@users.noreply.github.com> Date: Thu, 27 Jun 2024 12:18:19 -0500 Subject: [PATCH 16/17] Update content/postgresql/concepts/operator-invocations/operator-invocations.md Co-authored-by: shantanu <56212958+cigar-galaxy82@users.noreply.github.com> --- .../concepts/operator-invocations/operator-invocations.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/content/postgresql/concepts/operator-invocations/operator-invocations.md b/content/postgresql/concepts/operator-invocations/operator-invocations.md index 29d4c67aea4..b42007a579a 100644 --- a/content/postgresql/concepts/operator-invocations/operator-invocations.md +++ b/content/postgresql/concepts/operator-invocations/operator-invocations.md @@ -71,8 +71,7 @@ Here's an example of operator invocations on data in the table `animals`. ```sql -SELECT * from animals -WHERE gender = 'female' AND age >= 4; +SELECT * FROM animals WHERE gender = 'female' AND age >= 4; ``` Output: From 5bbe7b311ce7228c1e406ee1ec860f0b40d76ee1 Mon Sep 17 00:00:00 2001 From: Sriparno Roy Date: Wed, 3 Jul 2024 16:06:55 +0530 Subject: [PATCH 17/17] Minor changes --- .../operator-invocations.md | 98 ----------------- .../concepts/operators/operators.md | 100 ++++++++++++++++++ 2 files changed, 100 insertions(+), 98 deletions(-) delete mode 100644 content/postgresql/concepts/operator-invocations/operator-invocations.md create mode 100644 content/postgresql/concepts/operators/operators.md diff --git a/content/postgresql/concepts/operator-invocations/operator-invocations.md b/content/postgresql/concepts/operator-invocations/operator-invocations.md deleted file mode 100644 index b42007a579a..00000000000 --- a/content/postgresql/concepts/operator-invocations/operator-invocations.md +++ /dev/null @@ -1,98 +0,0 @@ ---- -Title: 'Operator Invocations' -Description: 'Used to perform operations on the data using operators.' -Subjects: - - 'Computer Science' - - 'Data Science' -Tags: - - 'Data' - - 'Operators' - - 'PostgreSQL' -CatalogContent: - - 'learn-sql' - - 'paths/data-science-foundations' - - 'paths/analyze-data-with-sql' - - 'paths/design-databases-with-postgresql' ---- - -In PostgreSQL, **operator invocations** allow operations to be executed on data in one or multiple tables in a database. They can be used for calculations, comparisons, joining, filtering, etc. - -> **Note:** These are common operators, but many others are available to use. - -## Syntax - -### Comparison Operators - -```pseudo -// Equal to -SELECT * FROM table_name -WHERE column1 = 'North'; - -// Not Equal to -SELECT * FROM table_name -WHERE column1 != column2; - -// Greater than -SELECT * FROM table_name -WHERE column1 > 10; - -// Less than -SELECT * FROM table_name -WHERE column1 < 1000; -``` - -### Logical Operators - -```pseudo -// AND -SELECT * FROM table_name -WHERE column1 >= 10 AND column1 <= 1000; - -// OR -SELECT * FROM table_name -WHERE column1 = 'North' OR 'WEST'; - -// NOT -SELECT * FROM table_name -WHERE NOT column1 = 'SOUTH'; -``` - - -## Example 1 - -Here's an example of operator invocations on data in the table `animals`. - -| `id` | `name` | `species` | `gender` | `age` | -| ---- | -------- | ----------- | ---------- | ------ | -| 01 | Niko | monkey | female | 3 | -| 02 | Frank | giraffe | male | 4 | -| 03 | Lyn | lion | female | 6 | -| 04 | Tom | elephant | male | 7 | - - -```sql -SELECT * FROM animals WHERE gender = 'female' AND age >= 4; -``` - -Output: - -| `id` | `name` | `species` | `gender` | `age` | -| ---- | -------- | ----------- | ---------- | ------ | -| 03 | Lyn | lion | female | 6 | - - -## Example 2 - -Using that same table, here is another operator invocation example. - -```sql -SELECT * FROM animals WHERE NOT species = 'lion'; -``` - -Output: - -| `id` | `name` | `species` | `gender` | `age` | -| ---- | -------- | ----------- | ---------- | ------ | -| 01 | Niko | monkey | female | 3 | -| 02 | Frank | giraffe | male | 4 | -| 04 | Tom | elephant | male | 7 | \ No newline at end of file diff --git a/content/postgresql/concepts/operators/operators.md b/content/postgresql/concepts/operators/operators.md new file mode 100644 index 00000000000..c9b9138c174 --- /dev/null +++ b/content/postgresql/concepts/operators/operators.md @@ -0,0 +1,100 @@ +--- +Title: 'Operators' +Description: 'Enable users to perform different operations on the data.' +Subjects: + - 'Computer Science' + - 'Data Science' +Tags: + - 'Data' + - 'Database' + - 'Operators' + - 'PostgreSQL' +CatalogContent: + - 'learn-sql' + - 'paths/analyze-data-with-sql' +--- + +In PostgreSQL, **operators** enable users to perform different operations on the data in one or multiple tables in a [database](https://www.codecademy.com/resources/docs/general/database). They can be used for calculations, comparisons, joining, filtering, etc. + +## Syntax + +There are many operators that can be used in PostgreSQL. Here are some common ones: + +### Comparison Operators + +The following operators can be categorized as comparison operators: + +```pseudo +// Equal to +SELECT * FROM table_name +WHERE column1 = 'North'; + +// Not Equal to +SELECT * FROM table_name +WHERE column1 != column2; + +// Greater than +SELECT * FROM table_name +WHERE column1 > 10; + +// Less than +SELECT * FROM table_name +WHERE column1 < 1000; +``` + +### Logical Operators + +The following operators can be categorized as logical operators: + +```pseudo +// AND +SELECT * FROM table_name +WHERE column1 >= 10 AND column1 <= 1000; + +// OR +SELECT * FROM table_name +WHERE column1 = 'NORTH' OR 'WEST'; + +// NOT +SELECT * FROM table_name +WHERE NOT column1 = 'SOUTH'; +``` + +## Examples + +The following examples demonstrate the usage of operators in PostgreSQL. + +Here's a table named `animals` to be used for the examples: + +| `id` | `name` | `species` | `gender` | `age` | +| ---- | ------ | --------- | -------- | ----- | +| 01 | Niko | monkey | female | 3 | +| 02 | Frank | giraffe | male | 4 | +| 03 | Lyn | lion | female | 6 | +| 04 | Tom | elephant | male | 7 | + +Here's a query that invokes some of the operators mentioned above: + +```sql +SELECT * FROM animals WHERE gender = 'female' AND age >= 4; +``` + +The above query results in the following output: + +| `id` | `name` | `species` | `gender` | `age` | +| ---- | ------ | --------- | -------- | ----- | +| 03 | Lyn | lion | female | 6 | + +Here's another query that invokes some operators: + +```sql +SELECT * FROM animals WHERE NOT species = 'lion'; +``` + +The above query produces the following output: + +| `id` | `name` | `species` | `gender` | `age` | +| ---- | ------ | --------- | -------- | ----- | +| 01 | Niko | monkey | female | 3 | +| 02 | Frank | giraffe | male | 4 | +| 04 | Tom | elephant | male | 7 |