Example: Input Records
Output Required:
For each id, values of code1 and code2 for code3="in" should get copied to values of code1 and code2 where code3="out".
I am doing:
select distinct id from input_table where code3="in";
Applying join and taking relevant columns after joining but not getting required result.
3
Answers
You can try this SQL replacing
your_table
with your table name.Assuming there is 1 ‘in’ row per id, you can use Max() Over() analytic function and Coalesce() to get your expected result.