After creating the following table, I want to extract the names of the countries with the lowest Quant on each continent - but I keep getting an error on the JOIN statement.
I tried various kinds of JOIN statements, but I keep getting an error on the penultimate line. There is no problem if I eliminate x.name and the last two lines (e.g. the lines containing the JOIN statement and its subsequent line) - i.e. the code extracts the initial query listing the minimum Quant in each continent, but fails on the JOIN statement.
| ---------|------|-----|
| continent| name |Quant|
| ---------|------|-----|
| Asia | SL | 140 |
| Asia | Iran | 56 |
| Asia | Iraq | 43 |
| Europe | Italy| 60 |
| Europe | Spain| 38 |
| Europe | Eire | 12 |
| Africa | Kenya| 56 |
| Africa | Zaire| 34 |
| Africa | Egypt| 130 |
|----------|------|-----|
SELECT y.continent, x.name, MIN(y.Quant)
FROM golf y
GROUP By y.continent
LEFT JOIN golf x
ON (y.continent = x.continent)
ALTERNATE variation below
SELECT y.continent, x.name, min(y.Quant)
FROM golf y
GROUP BY y.continent
LEFT OUTER JOIN (select x.continent, x.name FROM golf x)
ON (y.continent = x.continent)
The following is the message:
db error: ERROR: syntax error at or near "left"