Re: Daily SQL Quiz
Posted in 1993
Topics: SQL Development & Query Writing
It may be that even writing SQL code is more fun than working. (I
guess that only applies if your not being paid to write SQL code.)
Anyway, the problem is to
select the row from a table having the largest date
field among all rows of that table having the same task_Id.
The solution proposed by Aahz (whose .signature is to be commended) is
in the right direction but not at the proper destination. What is
needed here is a subquery to find the value of the date. Comme ca:
select whatever_you_want
from Table Outer
where date_field =
(select max(date_field)
from Table Inner
where Inner.task_id = outer.task_id);
Inner and Outer are called corelation names (but don't ask me why
they're called that).
Marc H. Graham Software Engineering Institute
marc@sei.cmu.edu Carnegie Mellon University
(412) 268 7784 Pittsburgh, PA 15213