left join with between date condition

Post questions here relative to DataStage Enterprise/PX Edition for such areas as Parallel job design, Parallel datasets, BuildOps, Wrappers, etc.

Moderators: chulett, rschirm, roy

Post Reply
vg
Participant
Posts: 5
Joined: Mon Sep 10, 2012 11:48 am

left join with between date condition

Post by vg »

Hi,

I need help in implementing following join logic.

Select * from Table A
Left outer join table B
on A.column1 = B.column1
and ((A.date1 between B.date1 and B.date2) or (A.date2 between B.date1 and B.date2))

First I used a Join and then used filter after that for date condition, but it gives me a wrong result.

Here both table A and B are files.

I under stood that left join and both date conditions should be done within Join.

Please let me know if there is way to get the correct result.
srinivas.g
Participant
Posts: 251
Joined: Mon Jun 09, 2008 5:52 am

Post by srinivas.g »

Use range lookup.
Srinu Gadipudi
vg
Participant
Posts: 5
Joined: Mon Sep 10, 2012 11:48 am

Post by vg »

I need pass rows that saitsfy either of the two range date conditions ((A.date1 between B.date1 and B.date2) or (A.date2 between B.date1 and B.date2)).

if i use 2 range conditions in lookup its treating as ''AND''....but my requirement is to use ''OR''..please let know how to achice this...
elsont
Participant
Posts: 16
Joined: Wed Oct 08, 2008 1:20 am
Location: Chicago

Post by elsont »

Then duplicate the input stream into two using copy stage. Do the first lookup on the first stream, second lookup on the second stream. Now funnel into one and remove duplicates
ssreeni3
Participant
Posts: 29
Joined: Fri May 18, 2012 1:35 am

Post by ssreeni3 »

Try this:
Please ensure In Sql query:
Between Minimum_Value AND Maximum_Value

Then It works properly.
---------------------------------------------------------------
Sreeni3
jwiles
Premium Member
Premium Member
Posts: 1274
Joined: Sun Nov 14, 2004 8:50 pm
Contact:

Post by jwiles »

You stated that the join followed by a filter did not work. What keys did you join on and what was the filter condition that you used? Was the data properly partitioned and sorted before the join?

Regards,
- james wiles


All generalizations are false, including this one - Mark Twain.
Post Reply