bluebottle
New Member
- Joined
- Feb 23, 2010
- Messages
- 12
I know microsoft query doesnt do field names very well, but it has never been a problem before as I could add them in to the SQL code in excel and they would work. But now it is causing me a problem when I use aggregate functions in subqueries.
Trying to use a generic example, if you have a table of soccer player names and ids, along with a table of goal times and player ids, the following query:
SELECT a.name, b.goals_scored
FROM players a
LEFT JOIN
(SELECT c.id, count(*) AS goals_scored FROM goals c GROUP BY c.id) b
ON a.id = b.id
will return the error 'Column b.goals_scored does not exist'.
Is there any way around this issue? I just need to be able to identify the field created by the aggregate function in the main query. It is causing me major hassles!
(This is a postgresql database by the way)
Trying to use a generic example, if you have a table of soccer player names and ids, along with a table of goal times and player ids, the following query:
SELECT a.name, b.goals_scored
FROM players a
LEFT JOIN
(SELECT c.id, count(*) AS goals_scored FROM goals c GROUP BY c.id) b
ON a.id = b.id
will return the error 'Column b.goals_scored does not exist'.
Is there any way around this issue? I just need to be able to identify the field created by the aggregate function in the main query. It is causing me major hassles!
(This is a postgresql database by the way)