Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Mailing Lists -> Oracle-L -> trouble with sql
There has got to be a way to do this but I can't find the syntax.
Essentially I need the max of column 3 grouped by column 1 and 2 and also the value of column 4 that corresponds to the returned columns 1,2, and 3.
Here is the actual sql that I believe to be using an unnecessary join:
select ps2.periodID, ps2.projectNumber, ps2.changeDate, ps3.statusID
from ( select p.periodID, ps.projectNumber, max(ps.changeDate) as
changeDate
from period p, projectStatus ps
where ps.changeDate >= trunc( p.startDate )
and trunc( ps.changeDate ) <= p.endDate group by p.periodID, ps.projectNumber ) ps2, projectStatus ps3 where ps2.projectNumber = ps3.projectNumber and ps2.changeDate = ps3.changeDate
Is there a better way to write this?
CONFIDENTIALITY NOTICE:
This message is intended for the use of the individual or entity to which it is addressed and may contain information that is privileged,
confidential and exempt from disclosure under applicable law. If the reader of this message is not the intended recipient or the employee or agent responsible for delivering this message to the intended recipient, you are hereby notified that any dissemination, distribution or copying of this communication is strictly prohibited. If you have received this
communication in error, please notify us immediately by email reply.
-- http://www.freelists.org/webpage/oracle-lReceived on Wed Jan 03 2007 - 14:33:31 CST
![]() |
![]() |