help formualting a query

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

help formualting a query

stan-9
I am having a hard time figuring out to do this, the SQL way. Doing in a
procedural way with a foreach would be deasy, but I suspect that a
properly formulated SQL query can achieve this.

I have a table that contains a  series of rows. Each row has a project key,
a start date, and an end date. There are multiple rows with different start
and end dates for each project.

I need to return something that contains, one row per project key, with the
min(star date) and max(end date) for ALL the records for that given
project.

Any suggestions?


--
"They that would give up essential liberty for temporary safety deserve
neither liberty nor safety."
                                                -- Benjamin Franklin


Reply | Threaded
Open this post in threaded view
|

Re: help formualting a query

Tom Lane-2
stan <[hidden email]> writes:
> I have a table that contains a  series of rows. Each row has a project key,
> a start date, and an end date. There are multiple rows with different start
> and end dates for each project.

> I need to return something that contains, one row per project key, with the
> min(star date) and max(end date) for ALL the records for that given
> project.

Maybe I'm misunderstanding something, but isn't this just

select project_key, min(start_date), max(end_date)
from my_table
group by project_key

??

                        regards, tom lane