Re: select row with greatest valued column - let me try again

2006-12-08 Thread Peter Bradley
Ysgrifennodd Tim McIntyre: Next pint is on me Peter;-) The following turned out to be exactly what I needed: SELECT s1.id FROM status_histories s1 WHERE s1.type = 'StatusHistoryOrder' AND s1.code = 1 AND s1.created_at = (SELECT MAX(s2.created_at) FROM statu

Re: select row with greatest valued column - let me try again

2006-12-08 Thread Tim McIntyre
Next pint is on me Peter;-) The following turned out to be exactly what I needed: SELECT s1.id FROM status_histories s1 WHERE s1.type = 'StatusHistoryOrder' AND s1.code = 1 AND s1.created_at = (SELECT MAX(s2.created_at) FROM status_histories s2

Re: select row with greatest valued column - let me try again

2006-12-08 Thread Peter Bradley
Ysgrifennodd Tim McIntyre: I tried that Peter and for some reason it's still selecting the oldest date not the newest??? Seems odd? Also I'd really like to just select id because I'll be using this in a subselect. Thanks! Tim SELECT s1.order_id FROM status_histories s1 WHERE s1.type = 'Statu

Re: select row with greatest valued column - let me try again

2006-12-08 Thread Tim McIntyre
I tried that Peter and for some reason it's still selecting the oldest date not the newest??? Seems odd? Also I'd really like to just select id because I'll be using this in a subselect. Thanks! Tim On Dec 8, 2006, at 10:31 AM, Peter Bradley wrote: Ysgrifennodd Tim McIntyre: Thanks for th

Re: select row with greatest valued column - let me try again

2006-12-08 Thread Peter Bradley
Ysgrifennodd Tim McIntyre: Thanks for the responses guys however I was running out the door yesterday and I oversimplified my problem. Sorry about that, let me try again. Here is my "status_histories" table with some data: id order_id code type

Re: select row with greatest valued column - let me try again

2006-12-08 Thread Tim McIntyre
Thanks for the responses guys however I was running out the door yesterday and I oversimplified my problem. Sorry about that, let me try again. Here is my "status_histories" table with some data: id order_id code type created_at 79 1