MySQL Forums
Forum List  »  Newbie

Re: How to join master/detail to retrieve lastest detail?
Posted by: Ramalingam Chelliah
Date: August 31, 2004 06:10AM

The idea is to concat the value whose max is considered with other fields and finding Max of the caoncatenated value and extracting the field value...
Try Like this ...

SELECT X.StationId, X.StationName,MAX(StatusDate) ,
SUBSTR( MAX(CONCAT(StatusDate,Metric1)),CHAR_LENGTH(StatusDate)+1) AS Metric1 ,

SUBSTR( MAX(CONCAT(StatusDate,Metric3)),CHAR_LENGTH(StatusDate)+1) AS Metric2 ,

MAX(CONCAT(StatusDate,Metric3)),CHAR_LENGTH(StatusDate)+1) AS Metric3 ,

FROM station as X,stationstatus
WHERE X.StationId=stationstatus.StationId
GROUP BY stationstatus.StationId ;

Hope this helps.....


We Learn the Most When we have to Invent

Options: ReplyQuote

Written By
Re: How to join master/detail to retrieve lastest detail?
August 31, 2004 06:10AM

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.