SQLTeam.com | Weblogs | Forums

SQL - Join


#1

Hello Experts,

I need your guidance on building a dynamic join. I have two tables ( Transaction and Master ) . The Master table contains rules and the transaction data must refer to the rules to pull the correct record.
The master table contains 25 fields + VALUE field. For a particular combination, few of the fields from the 25 will have entry and will give a value field.

image

My transaction table will contain all the 25 fields and I would like to join all the 25 fields from the transaction to the master table but want to join only those fields that has data to fetch the VALUE field.
To keep it simple, I would like to join all the 25 fields in the transaction to the master but want a dynamic join to happen based on the data availability for the fields in the master table. Any suggestions or guidance pls? FYI, we are on HANA DB.

Thanks,
Prem


#2

Hello Experts,

Any suggestions?

Thank you.


#3

IIUC you'll need a series of:

ON/WHERE trans.col is not null and trans.col = master.col