galaxy0815
Technical User
Hello,
I have an issue with a query I need to create. The following in my Basic table with the name ClientAddress:
Clientnr----------AddressLine---------Country---------Stopdate
47-----------------Mainstrett3---------GERMANY---------30.Nov.2010
47-----------------Obamastreet3--------USA-------------01.Feb.2011
47-----------------Boulevard3----------USA-------------01.Oct.2011
47-----------------Rue7----------------FRANCE----------31.Dec.9999
588----------------Neustrasse3---------GERMANY---------31.Dec.9999
899----------------Uferstrasse4--------GERMANY---------25.Mar.2012
899----------------Boulevard78---------UK--------------31.Dec.9999
.....
So it stores historical addresses (the ones that have a Stopdate<>31.Dec.9999) and current valid addresses (Stopdate=31.Dec.9999) for quite a number of clients. In total there are around 20,000 lines in the table.
I need to write now an SQL statement (No stored procedure etc as my user does not have the rights for this) that reports me any country change in the following way (Based on the above example) (in case there is a new address record, but within the same country, this can be ignored):
Clientnr---------------Old_Country-------------NEW_Country---------Changedate
47---------------------GERMANY-----------------USA-----------------30.Nov.2010
47---------------------USA---------------------FRANCE--------------01.Oct.2011
899--------------------GERMANY-----------------UK------------------25.Mar.2012
...
Does anyone know who to do this? I tried to solve it via recursive SQL(seems for me to be the only way), read now 2 hours about it, but to be honest I do not know how to use this powerful functionality as I never worked with it till now.
Can anyone help me with this issue here, please? Thanks in advance
I have an issue with a query I need to create. The following in my Basic table with the name ClientAddress:
Clientnr----------AddressLine---------Country---------Stopdate
47-----------------Mainstrett3---------GERMANY---------30.Nov.2010
47-----------------Obamastreet3--------USA-------------01.Feb.2011
47-----------------Boulevard3----------USA-------------01.Oct.2011
47-----------------Rue7----------------FRANCE----------31.Dec.9999
588----------------Neustrasse3---------GERMANY---------31.Dec.9999
899----------------Uferstrasse4--------GERMANY---------25.Mar.2012
899----------------Boulevard78---------UK--------------31.Dec.9999
.....
So it stores historical addresses (the ones that have a Stopdate<>31.Dec.9999) and current valid addresses (Stopdate=31.Dec.9999) for quite a number of clients. In total there are around 20,000 lines in the table.
I need to write now an SQL statement (No stored procedure etc as my user does not have the rights for this) that reports me any country change in the following way (Based on the above example) (in case there is a new address record, but within the same country, this can be ignored):
Clientnr---------------Old_Country-------------NEW_Country---------Changedate
47---------------------GERMANY-----------------USA-----------------30.Nov.2010
47---------------------USA---------------------FRANCE--------------01.Oct.2011
899--------------------GERMANY-----------------UK------------------25.Mar.2012
...
Does anyone know who to do this? I tried to solve it via recursive SQL(seems for me to be the only way), read now 2 hours about it, but to be honest I do not know how to use this powerful functionality as I never worked with it till now.
Can anyone help me with this issue here, please? Thanks in advance