Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: SELECT / UNION Giving Different Results
"DA Morgan" <damorgan_at_psoug.org> wrote in message
news:1183213601.534028_at_bubbleator.drizzle.com...
> Dereck L. Dietz wrote:
> > We've had a very strange (and possibly troubling) event happen.
>
> I've read Mark and Vladimir's responses to you and agree with them
> but I'd like to pile on.
>
> In addition to version ... Where's your SQL statement? We are in
> no position to evaluate what you are doing without seeing DDL and DML.
>
> Before you repost try this:
>
> Insert into each table one record that you know will connect to the
> other 19 using your query but not to any other existing record. Test
> your query then.
>
> If you are still having problems post a test case with version, explain
> plan created using dbms_xplan, and a complete copy of the actual SQL.
> --
> 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
Version - 10.2.0.3.0
OS - Windows 2003 Server
Memory - 8 GB
In the production version we identified a row from the HMP_COPD_CLAIMS table which didn't make it into the T_HB_DATES table (and hence not into the production DATES table).
In the test where I re-ran the code below the test table I created contained
the row which didn't make
it into the T_HB_DATES table before.
Once we identified that there were missing rows I took my test table and compared it against the production dates table and created a table of the missing rows. When I did a count of rows grouped by Type it showed that missing rows spanned all the tables from the select statement and weren't just specific to the HMP_COPD_CLAIMS table.
There has been no changes made to the source tables between the production run and my test run.
I don't have off-site access to the database so I won't be able to run anything else until Monday.
Also, this is inherited code so please don't blame me for the use of reserved words as column names.
CREATE TABLE T_HB_DATES
NOLOGGING
AS
--ASTHMA--
A.MBR_SYS_KEY, A.MBR_KEY, 'AM' AS TYPE, A."DATE" AS "DATE", A.SOURCE AS DTSOURCE
A.MBR_SYS_KEY, A.MBR_KEY, TYPE, A."DATE" AS "DATE", DTSOURCE
A.MBR_SYS_KEY, A.MBR_KEY, CASE WHEN TRIM(SOURCE)='E' THEN 'EA' WHEN TRIM(SOURCE)='I' THEN 'IA' END AS TYPE, A."DATE" AS "DATE", A.SOURCE AS DTSOURCE
--CHF--
A.MBR_SYS_KEY, A.MBR_KEY, 'OC' AS TYPE, A."DATE" AS "DATE", A.SOURCE AS DTSOURCE
A.MBR_SYS_KEY, A.MBR_KEY, TYPE, A."DATE" AS "DATE", DTSOURCE
A.MBR_SYS_KEY, A.MBR_KEY, 'DU' AS TYPE, A."DATE" AS "DATE", DTSOURCE
A.MBR_SYS_KEY, A.MBR_KEY, CASE WHEN TRIM(SOURCE)='E' THEN 'EC' WHEN TRIM(SOURCE)='I' THEN 'IC' END AS TYPE, A."DATE" AS "DATE", A.SOURCE AS DTSOURCE
--DIABETES--
A.MBR_SYS_KEY, A.MBR_KEY, 'OD' AS TYPE, A."DATE" AS "DATE", '1' AS DTSOURCE
A.MBR_SYS_KEY, A.MBR_KEY, CASE WHEN TRIM(SOURCE)='E' THEN 'ED' WHEN TRIM(SOURCE)='I' THEN 'ID' END AS TYPE, A."DATE" AS "DATE", '1' AS DTSOURCE
A.MBR_SYS_KEY, A.MBR_KEY, A.TYPE, A."DATE", A.DTSOURCE
A.MBR_SYS_KEY, A.MBR_KEY, A.TYPE, A."DATE", DTSOURCE
A.MBR_SYS_KEY, A.MBR_KEY, A.TYPE, A."DATE", A.DTSOURCE
A.MBR_SYS_KEY, A.MBR_KEY, A.TYPE, A."DATE", A.DTSOURCE
A.MBR_SYS_KEY, A.MBR_KEY, A.TYPE, A."DATE", A.DTSOURCE
--Cardiovascular DISEASE--
A.MBR_SYS_KEY, A.MBR_KEY, A.TYPE, A."DATE" AS "DATE", A.SOURCE AS DTSOURCEFROM T_HB_CVC_AM_TB A
A.MBR_SYS_KEY, A.MBR_KEY, A.TYPE, A."DATE" AS "DATE", A.SOURCE AS DTSOURCE
A.MBR_SYS_KEY, A.MBR_KEY, A.TYPE, A."DATE" AS "DATE", A.SOURCE AS DTSOURCE
--MIGRAINE-- ---------------------------------------------SELECT DISTINCT
A.MBR_SYS_KEY, A.MBR_KEY, A.TYPE, A."DATE" AS "DATE", A.SOURCE AS DTSOURCE
A.MBR_SYS_KEY, A.MBR_KEY, A.TYPE, A."DATE" AS "DATE", A.SOURCE AS DTSOURCE
--TENSION HEADACHE(MIGRAINE)--
A.MBR_SYS_KEY, A.MBR_KEY, A.TYPE, A."DATE" AS "DATE", A.SOURCE AS DTSOURCE
A.MBR_SYS_KEY, A.MBR_KEY, A.TYPE, A."DATE" AS "DATE", A.SOURCE AS DTSOURCE
A.MBR_SYS_KEY, A.MBR_KEY, A.TYPE, A."DATE" AS "DATE", A.DTSOURCE
--LOW BACK PAIN--
A.MBR_SYS_KEY, A.MBR_KEY, A.TYPE, A."DATE" AS "DATE", A.SOURCE AS DTSOURCE
A.MBR_SYS_KEY, A.MBR_KEY, A.TYPE, A."DATE" AS "DATE", A.SOURCE AS DTSOURCE