Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: SQL Statement Help

Re: SQL Statement Help

From: Ed Prochak <edprochak_at_gmail.com>
Date: 18 Jul 2006 13:26:33 -0700
Message-ID: <1153254393.487624.147750@35g2000cwc.googlegroups.com>

Kobee wrote:
> Hi,
>
> I've been trying to get this SQL, but I just can't get it to work. It
> should a be a relatively simple SELECT on a single table, with 2
> criteria - a date range for "lastupdate". Basically it's like "give me
> all the records from this table where the lastupdate is between
> startdate and enddate." There's one catch, though. There are three
> types of "transaction_types" in this table: "Add", "Update", "Delete".
> If the type is "Update", then there will be always be 2 records, with
> possibly different lastupdate values. The catch is that this SQL has to
> return the second "Update" row, even if it has a lastupdate outside of
> the specified date range. What's the best way to accomplish this?
>
> Thanks in advance for any help. My SQL is not up to par...

It all boils down to problem solving skills.

Since teh rules for the Update types are different, put that in a different query than the Add and Delete types. When you have both subqueries working, just union the results together.

HTH,
   ed Received on Tue Jul 18 2006 - 15:26:33 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US