I need to check (here for an example) if the average earnings of DE workers are higher than IT workers. I tried using
SELECT IF(
(SELECT AVG(earnings) FROM workers WHERE country LIKE 'DE') >
(SELECT AVG(earnings) FROM workers WHERE country LIKE 'IT'),
'True', 'False');
but it doesn't seem to work. Is there any way to do this in PostgresSQL (I am using version 14)
| first_name | last_name | country | earnings |
|---|---|---|---|
| Andrea | Pfeiffer | DE | 800 |
| Eufrosina | Marchesi | IT | 2975 |
| Elisa | Sabbatini | IT | 2450 |
| Marco | Grunewald | DE | 3000 |
| Doreen | Kalb | DE | 5000 |
| Isidoro | Bruno | IT | 1100 |
| Lucas | Mueller | DE | 3000 |
| Ausonio | Loggia | IT | 1300 |