Hi all,
I have a scenario which goes like this.
i have a dimension table named 'customer' with columns customer id,customer name and address.
If a particular customer say A,keeps changing his address,how do i bring in those changes in my customer table.
Conditions are that all the previous addresses should also be preserved,eff date or time stamp shd not be used.And also when the end-user enquires about the customer A,he shd get the latest details about him.
Can anyone clarify me?
how to get the latest record from dimension table?
Moderators: chulett, rschirm, roy
-
- Premium Member
- Posts: 45
- Joined: Tue Aug 29, 2006 2:59 am
- Location: Bangalore
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
Create a query that constrains on the customer ID and the most recent (probably maximum) surrogate key value via a correlated subquery.
Code: Select all
SELECT T1.CUSTOMER_KEY
FROM CUSTOMER_DIM T1
WHERE CUSTOMER_ID = 'A'
AND T1.CUSTOMER_KEY = (SELECT MAX(T2.CUSTOMER_KEY)
FROM CUSTOMER_DIM T2
WHERE T1.CUSTOMER_ID = T2.CUSTOMER_ID);
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
If timestamp or data shouldnt be used, then to fetch the latest information, you need to have another column which represents the version of the data. Or as simply utilizing the surrogate key as Ray suggested, which will increase sequentially.
Impossible doesn't mean 'it is not possible' actually means... 'NOBODY HAS DONE IT SO FAR'