I have two tables "customer" and "activation" that I would like to join. Here are their structures:
CUSTOMER Activation
------------ -------------
Id Name EntityId Date_Created Type
1 A 1 2012 EMAIL
2 B 2 2011 SMS
3 C
Now, I would like to join those two tables on customer.Id = Activation.EntityId. However, i want my final table structure to be like this:
Id Name Date_Email Date_SMS
1 A 2012 NULL
2 B NULL 2011
Basically, the columns Date_Email and Date_SMS both come from Activation.Date_Created column. IF Activation.Type is EMAIL, i set Date_Email in my final result to Date_created and set Date_SMS to null. If Activation.type is SMS, i do it the other way.
What i have right now is this:
SELECT Customer.Id, Name, Date_Created AS Date_EMail, DATE_Created AS Date_SMS
from Customer
inner join Activation ON Customer.Id = Activation.EntityId;
Now, i need to make a If-else condition based on Activation.Type column. I am quite new to this and I have not been able to figure this out by googling. I am using Oracle XE database btw
Can someone help me with this? Thanks
Activationfor each type and EntityId combination?