Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Completed concept entry for Postgresql operators #4764 #4785

Merged
Merged
Changes from 9 commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
c9f7959
added shell for concept
nbarnhouse Jun 3, 2024
53c085b
completed first draft of operator-invocations
nbarnhouse Jun 12, 2024
a884d8b
Merge branch 'Codecademy:main' into main
nbarnhouse Jun 12, 2024
5de5292
added shell for file structure
nbarnhouse Jun 13, 2024
5e4b65e
completed description and syntax, working through examples now
nbarnhouse Jun 15, 2024
7783c09
completed initial write up of numpy.degrees
nbarnhouse Jun 17, 2024
88ef147
corrected missing description
nbarnhouse Jun 17, 2024
2c9017f
corrected md file with missing description
nbarnhouse Jun 17, 2024
8ae7e64
removing file added in error
nbarnhouse Jun 17, 2024
a48af58
Update content/postgresql/concepts/operator-invocations/operator-invo…
nbarnhouse Jun 27, 2024
3ea051a
Update content/postgresql/concepts/operator-invocations/operator-invo…
nbarnhouse Jun 27, 2024
61e08be
Update content/postgresql/concepts/operator-invocations/operator-invo…
nbarnhouse Jun 27, 2024
2ea31a5
Update content/postgresql/concepts/operator-invocations/operator-invo…
nbarnhouse Jun 27, 2024
dff8c89
Update content/postgresql/concepts/operator-invocations/operator-invo…
nbarnhouse Jun 27, 2024
23b2acd
Update content/postgresql/concepts/operator-invocations/operator-invo…
nbarnhouse Jun 27, 2024
ff28c5f
Update content/postgresql/concepts/operator-invocations/operator-invo…
nbarnhouse Jun 27, 2024
d714e37
Update content/postgresql/concepts/operator-invocations/operator-invo…
nbarnhouse Jun 27, 2024
f7f8632
Merge branch 'main' into postgresql-operator_invocations
Sriparno08 Jul 3, 2024
5bbe7b3
Minor changes
Sriparno08 Jul 3, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
---
Title: 'Operator Invocations'
Description: 'The execution of operations on data.'
nbarnhouse marked this conversation as resolved.
Show resolved Hide resolved
Subjects:
- 'Computer Science'
- 'Data Science'
Tags:
- 'Data'
- 'Operators'
- 'PostgreSQL'
CatalogContent:
- 'learn-sql'
- 'paths/data-science-foundations'
nbarnhouse marked this conversation as resolved.
Show resolved Hide resolved
---

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.
nbarnhouse marked this conversation as resolved.
Show resolved Hide resolved

Note: These are common operators, but there are many others avaiable to use.
nbarnhouse marked this conversation as resolved.
Show resolved Hide resolved

## 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;
nbarnhouse marked this conversation as resolved.
Show resolved Hide resolved
```

### 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';
nbarnhouse marked this conversation as resolved.
Show resolved Hide resolved
```


## 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;
nbarnhouse marked this conversation as resolved.
Show resolved Hide resolved
```

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';
nbarnhouse marked this conversation as resolved.
Show resolved Hide resolved
```

Output:

| `id` | `name` | `species` | `gender` | `age` |
| ---- | -------- | ----------- | ---------- | ------ |
| 01 | Niko | monkey | female | 3 |
| 02 | Frank | giraffe | male | 4 |
| 04 | Tom | elephant | male | 7 |
Loading