Hi Fred

thanks for your response, i tested your solution and it works fine. but 
its not quite as easy as ive posted above, the row im searching for in 
the outcomes table isnt always as row 1.

so hardcoding a value in the controller is a no no.

the outcomes table i am working with, looks more like this:

+----+---------------------+-------------+------------+-----------+
| id | outcome_date        | testcase_id | testrun_id | result_id |
+----+---------------------+-------------+------------+-----------+
|  1 | 2008-09-22 11:51:28 |           1 |         16 |         4 |
|  2 | 2008-09-22 12:23:10 |           1 |         26 |         1 |
|  3 | 2008-09-22 12:31:00 |           1 |         26 |      NULL |
|  4 | 2008-09-22 13:25:44 |           1 |         26 |         3 |
|  5 | 2008-09-22 13:29:52 |           1 |         26 |         2 |
|  6 | 2008-09-22 13:33:33 |           1 |         26 |         2 |

and i need to retrieve the most recent outcome_date for testcase_id 1, 
similarly i also need to retrieve the resulttype from the results 
table(shown below) by using the join on outcomes.result_id -> 
results.id, also for the most recent outcomes.outcome_date

+----+------------+
| id | resulttype |
+----+------------+
|  1 | Pass       |
|  2 | Fail       |
|  3 | N/A        |
|  4 | Not Run    |
+----+------------+

as you can see, a simple sql statement would be much more viable as an 
option, but as you state the find_by_sql isnt so useful, i am wondering 
how such querying can be resolved in rails.

ive seen a variety of first, last, etc... but this seems like a lengthy 
way of doing things? and im not even sure it can be done.

although i am a newbie...

thanks for your help though.
-- 
Posted via http://www.ruby-forum.com/.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to