Skip to content
Advertisement

SELECT Data with logic created date not greater than

I have three tables with detail structure and data like this :

  1. Table TBL_REFERRAL

  2. Table TBL_USER

  3. Table TBL_CHECKOUT

Because of some conditions, in the process I can’t connect between checkout table and referral. But I want to have a view table that connecting the checkout with referral but I am map that with logic based on created date time between referral and check out. Is it possible to me have the view table like this ? :

Updated -> I have been try the query like this :

The result come is :

So, based on my result and expectation there is still missing 1 filtering. In this condition c.CREATED_DATE > a.CREATED_DATE, if a.CREATED_DATE that smaller then c.CREATED_DATE is more than 1. the data show 2 row, it should be just one, get latest a.CREATED_DATE. If i using ROW_NUMBER in logic it will be disturb row EM0003 & 1113 and EM0004 & 1114.

based on my current result, i want to grouping the transaction_id get based on latest REFERRAL_DATE, is it possible ?

Thank you so much for help I really appreciate it

Advertisement

Answer

You can use LEFT JOIN among those three tables, and ROW_NUMBER() analytic function is need to filter out the records among latest CHECKOUT_DATE values :

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement