S
snufa snafu
hey volks.
i'm struggeling really hard on this one! basically i just want to get
the groupwise maximum (in this case the latest entries /
ranks.checked_at). i try something like this:
SELECT urls.url, keywords.keyword, ranks.rank
FROM (urls INNER JOIN keywords ON urls.ID = keywords.url_id) INNER
JOIN ranks ON keywords.ID = ranks.keyword_id AS xxx,
(SELECT keywords.keyword, MAX(ranks.checked_at) AS latest FROM
keywords INNER JOIN ranks ON keywords.ID = ranks.keyword_id GROUP BY
keywords.keyword) AS yyy
WHERE yyy.keyword = xxx.keyword
AND xxx.created_at = yyy.latest;
but it seems as if the 'AS xxx' statement isn't valid after INNER
JOINs of tables...
please help me, i'm really lost!
thanks so much,
-bernd
i'm struggeling really hard on this one! basically i just want to get
the groupwise maximum (in this case the latest entries /
ranks.checked_at). i try something like this:
SELECT urls.url, keywords.keyword, ranks.rank
FROM (urls INNER JOIN keywords ON urls.ID = keywords.url_id) INNER
JOIN ranks ON keywords.ID = ranks.keyword_id AS xxx,
(SELECT keywords.keyword, MAX(ranks.checked_at) AS latest FROM
keywords INNER JOIN ranks ON keywords.ID = ranks.keyword_id GROUP BY
keywords.keyword) AS yyy
WHERE yyy.keyword = xxx.keyword
AND xxx.created_at = yyy.latest;
but it seems as if the 'AS xxx' statement isn't valid after INNER
JOINs of tables...
please help me, i'm really lost!
thanks so much,
-bernd