Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Getting Close need a Max Field can you help

Status
Not open for further replies.

SuperSqlr

Programmer
Apr 13, 2004
6
US
I have this query to retun the results froma single table with six columns...They are Proc_id,anest,start_time,start_date,end_time,end_time...
This is returning all procedures that overlap by setting a timestamp and InnerJoin to compare those that overlap. I am triing to return the Max procedures that overlap, but when I use a select max (the query) As whatever FROM anest_procedures; It won't run, I am using Postgres(PGAdminIII).Thanks in advanced...

SELECT a.proc_id, Count(a.proc_id), a.anest

FROM anest_procedures AS a,
anest_procedures AS b

WHERE (CAST (a.start_date || ' ' || a.start_time AS TimeStamp), CAST (a.end_date || ' ' || a.end_time AS TimeStamp))
OVERLAPS (CAST (b.start_date || ' ' || b.start_time AS TimeStamp), CAST (b.end_date || ' ' || b.end_time AS TimeStamp))
AND
b.anest = a.anest
GROUP BY a.proc_id, a.anest
Order by a.proc_id;
 
You may have different start/end timestamps for same proc_id,anest pair ?

Hope This Help, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884
 
That is the point I needed different timstamps to determine the range for the Overlap. What I need to figure out is how to select the Max count...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top