November 17, 2016 at 3:28 am
Hi All,
I am inserting data from customer table to fact_customer
customer table has duplicate records with Customer ids but some of columns having different data i want to combine this in one row
eg.
Customer table
id name addess city phone email business_email
1A mumbaimumbai98205140014A@gmail.com NULL
1A mumbaimumbai98205140014NULL a@company.com
I want single row having data using SQL SERVER 2012 SQL
id name addess city phone email business_email
1A mumbaimumbai98205140014A@gmail.coma@company.com
is there any efficient SQL for this
November 17, 2016 at 3:41 am
How do you decide between mumbai and Pune?
- Damian
November 17, 2016 at 3:45 am
Updated. they are same some other columns are having null and data subsequently
November 17, 2016 at 4:46 am
This might help:
http://stackoverflow.com/questions/27927251/remove-duplicates-with-less-null-values
Rather than remove, just take the select part
Unless you are looking to remove the records?
- Damian
November 17, 2016 at 5:45 am
Gaja (11/17/2016)
Hi All,I am inserting data from customer table to fact_customer
customer table has duplicate records with Customer ids but some of columns having different data i want to combine this in one row
eg.
Customer table
id name addess city phone email business_email
1A mumbaimumbai98205140014A@gmail.com NULL
1A mumbaimumbai98205140014NULL a@company.com
I want single row having data using SQL SERVER 2012 SQL
id name addess city phone email business_email
1A mumbaimumbai98205140014A@gmail.coma@company.com
is there any efficient SQL for this
You need to define two things:
1) Which combination of columns needs to be the same such that the rows are considered duplicates?
2) For the remaining columns, what are the rules for selecting the 'winning' piece of data?
When you have these worked out, the rest is relatively straightforward (assuming the rules established in (2) are not overly complex).
The absence of evidence is not evidence of absence
- Martin Rees
The absence of consumable DDL, sample data and desired results is, however, evidence of the absence of my response
- Phil Parkin
November 17, 2016 at 7:39 am
Gaja (11/17/2016)
Hi All,I am inserting data from customer table to fact_customer
customer table has duplicate records with Customer ids but some of columns having different data i want to combine this in one row
eg.
Customer table
id name addess city phone email business_email
1A mumbaimumbai98205140014A@gmail.com NULL
1A mumbaimumbai98205140014NULL a@company.com
I want single row having data using SQL SERVER 2012 SQL
id name addess city phone email business_email
1A mumbaimumbai98205140014A@gmail.coma@company.com
is there any efficient SQL for this
This sounds more like a slowly changing dimension table rather than a fact table. A fact table usually models some kind of transactional business process, and this seems like descriptive data about a customer at different points in time.
I'd recommend the Kimball Group for learning more about star schema fact and dimension table design:
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply