By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0.
| version |
|---|
| PostgreSQL 14.5 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 8.5.0 20210514 (Red Hat 8.5.0-10), 64-bit |
SELECT 1
CREATE TABLE
INSERT 0 6
| id | fruit_name | purchase_date |
|---|---|---|
| 1 | apple | 2020-02-01 |
| 2 | pear | 2020-02-01 |
| 3 | orange | 2020-02-01 |
| 4 | apple | 2020-02-01 |
| 5 | grapes | 2020-02-03 |
| 6 | grapes | 2020-02-04 |
SELECT 6
| purchase_date | same_date_purchases |
|---|---|
| 2020-02-03 | 1 |
| 2020-02-04 | 1 |
| 2020-02-01 | 4 |
SELECT 3