By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0.
CREATE TABLE
INSERT 0 5
| id | title | type |
|---|---|---|
| 4 | title4 | SuperSpecial |
| 2 | title2 | Special |
| 3 | title3 | Ordinary |
| 5 | title5 | null |
| 1 | title1 | Some Type |
SELECT 5
| id | title | type |
|---|---|---|
| 4 | title4 | SuperSpecial |
| 2 | title2 | Special |
| 3 | title3 | Ordinary |
| 5 | title5 | null |
| 1 | title1 | Some Type |
SELECT 5
ERROR: function array_position(character varying[], text) does not exist LINE 5: array_position(ARRAY['SuperSpecial','Special','Ordinary']:... ^ HINT: No function matches the given name and argument types. You might need to add explicit type casts.
CREATE FUNCTION
| id | title | type | published_at |
|---|---|---|---|
| 4 | title4 | SuperSpecial | 2021-11-04 15:00:00 |
| 2 | title2 | Special | 2021-11-04 13:00:00 |
| 3 | title3 | Ordinary | 2021-11-04 14:00:00 |
| 5 | title5 | null | 2021-11-04 16:00:00 |
| 1 | title1 | Some Type | 2021-11-04 12:00:00 |
SELECT 5
| id | title | type | published_at |
|---|---|---|---|
| 5 | title5 | null | 2021-11-04 16:00:00 |
| 4 | title4 | SuperSpecial | 2021-11-04 15:00:00 |
| 3 | title3 | Ordinary | 2021-11-04 14:00:00 |
| 2 | title2 | Special | 2021-11-04 13:00:00 |
| 1 | title1 | Some Type | 2021-11-04 12:00:00 |
SELECT 5