J
JoJo S via AccessMonster.com
I have exhausted all my means as to why this qry does not work on vast volume
of data when it works on smaller amount of data. Thanks to anyone who would
offer advice. Table1 is on Access and Table2 in a data warehouse which I
access through ODBC.
The query employs two tbls:
Table1
Id DOS
10 1/5/2004
10 2/5/2004
11 3/5/2004
12 4/5/2004
13 5/5/2004
13 6/5/5004
13 7/5/2004
Table2
Id PlanStartDt PlanEndDt Plan
10 1/1/2003 1/31//2004 P1
10 2/1/2004 3/31/2004 P1
11 1/1/2004 12/31/2004 P3
13 1/1/2004 6/31/2004 P4
My query goes like:
SELECT table1.id, table1.DOS, Table2.Plan, iif(table2.id is not null, “y”,”n”)
as PlanCovg
INTO NewTable
FROM table1
LEFT JOIN table2
ON table1.id=table2.id AND table1.dos between table2.PlanStartDt and table2.
PlanEndDate
Table1 has over 130k records. The query result should be like:
Id DOS PLAN PlanCovg
10 1/5/2004 P1 Y
10 2/5/2004 P1 Y
11 3/5/2004 P3 Y
12 4/5/2004 N
13 5/5/2004 P4 Y
13 6/5/5004 P4 Y
13 7/5/2004 N
When I run the query based on over 130k records from table1, it won’t return
all records for situations like id=13 (from tbl1) where some of the dos from
table1 is covered by plan from table2 and some others not. It drops the
records where dos is not covered by plan totally. See below.
But the strange thing is that if I make table1 contain smaller number of
records, I get correct return.
13 5/5/2004 P4 Y
13 6/5/5004 P4 Y
13 7/5/2004 N (This record is dropped when I run on bulky table1, but stays
when I run on smaller amount of data)
Thank you very much!!!
of data when it works on smaller amount of data. Thanks to anyone who would
offer advice. Table1 is on Access and Table2 in a data warehouse which I
access through ODBC.
The query employs two tbls:
Table1
Id DOS
10 1/5/2004
10 2/5/2004
11 3/5/2004
12 4/5/2004
13 5/5/2004
13 6/5/5004
13 7/5/2004
Table2
Id PlanStartDt PlanEndDt Plan
10 1/1/2003 1/31//2004 P1
10 2/1/2004 3/31/2004 P1
11 1/1/2004 12/31/2004 P3
13 1/1/2004 6/31/2004 P4
My query goes like:
SELECT table1.id, table1.DOS, Table2.Plan, iif(table2.id is not null, “y”,”n”)
as PlanCovg
INTO NewTable
FROM table1
LEFT JOIN table2
ON table1.id=table2.id AND table1.dos between table2.PlanStartDt and table2.
PlanEndDate
Table1 has over 130k records. The query result should be like:
Id DOS PLAN PlanCovg
10 1/5/2004 P1 Y
10 2/5/2004 P1 Y
11 3/5/2004 P3 Y
12 4/5/2004 N
13 5/5/2004 P4 Y
13 6/5/5004 P4 Y
13 7/5/2004 N
When I run the query based on over 130k records from table1, it won’t return
all records for situations like id=13 (from tbl1) where some of the dos from
table1 is covered by plan from table2 and some others not. It drops the
records where dos is not covered by plan totally. See below.
But the strange thing is that if I make table1 contain smaller number of
records, I get correct return.
13 5/5/2004 P4 Y
13 6/5/5004 P4 Y
13 7/5/2004 N (This record is dropped when I run on bulky table1, but stays
when I run on smaller amount of data)
Thank you very much!!!