MySQL Forums
Forum List  »  Newbie

Re: Long but easy question for an Expert
Posted by: David Fells
Date: March 24, 2005 04:41PM

Before i answer this question, you shouldn't name tables with a _table prefix. The fact that they exist as tables in the schema is enough, there's no need to say "this table is a table" =)

If I am reading your question correctly, the only problem with your query is the fact that you are not grouping on location after ra_number. Any non-aggreate columns that you want to select must appear in the GROUP BY clause.

SELECT
MAX(transaction_number), ra_number, location
FROM
trans_table
INNER JOIN location_table USING (location)
WHERE
trans_table.location != 'Shipped'
GROUP BY
trans_table.ra_number, trans_table.location

Options: ReplyQuote


Subject
Written By
Posted
Re: Long but easy question for an Expert
March 24, 2005 04:41PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.