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: <nkunkov_at_escholar.com>
Date: 6 Jul 2006 11:13:49 -0700
Message-ID: <1152209629.673345.72650@m73g2000cwd.googlegroups.com>

Kobee wrote:
> Oracle 9i
>
> SELECT
> PROGRAM_ID, PROGRAM_TYPE, ANNUALBUDGETTYPE, DESCRIPTION, NAME,
> NVL(SPLIT_FEDERAL, 0) AS "SPLIT_FEDERAL", NVL(SPLIT_MUNICIPAL, 0) AS
> "SPLIT_MUNICIPAL", NVL(SPLIT_PROVINCIAL, 0) AS "SPLIT_PROVINCIAL",
> AFS_FLAG, CAPITALPLAN_FLAG, CER_FLAG, HPEMS_FLAG, START_DATE,
> RENTSUP_FLAG,
> BENCHMARK_FLAG, STATUS, NVL(SUBSIDY_CC, 0) AS "SUBSIDY_CC",
> LASTUPDATE, NVL(SUBSIDY_CE, 0) AS "SUBSIDY_CE",
> DATE_CREATED, TRANSACTION_TYPE, MODIFIED_BY, TRANSACTION_ID,
> TRANSACTION_ORDER
> FROM
> PROGRAM_LOG
> WHERE
> TO_DATE(TO_CHAR(LASTUPDATE, 'yyyy-Mon-dd'), 'yyyy-Mon-dd') BETWEEN
> TO_DATE(dtstartdate, 'yyyy-Mon-dd') AND TO_DATE(dtenddate,
> 'yyyy-Mon-dd')
> OR
> TRANSACTION_TYPE = 'U'
> ORDER BY
> TRANSACTION_ID,
> TRANSACTION_ORDER,
> LASTUPDATE DESC;
>
>
> I' ve tried several approaches, but so far the "OR" statement is coming
> closest to what I need. The only problem is that the OR clause will
> return records whether or not there is a corresponding "Update" row
> within the date range.
>
> Thanks
>
>
> DA Morgan wrote:
> > Kobee wrote:
> > > Hi,
> > >
> > > I've been trying to get this SQL, but I just can't get it to work.
> >
> > Where is your SQL?
> >
> > We can't help you with it if you don't post it.
> >
> > And your Oracle version number?
> > --
> > Daniel A. Morgan
> > University of Washington
> > damorgan_at_x.washington.edu
> > (replace x with u to respond)
> > Puget Sound Oracle Users Group
> > www.psoug.org

I would split your query into two subqueries. One with the where clause of a date range, the other with the transaction_type. Then either join two subqueries or do a union. Hope it helps a bit. NK Received on Thu Jul 06 2006 - 13:13:49 CDT

Original text of this message

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