A query to flaten, denormalize data.
Hi,
I'm not too sure whats the best way to go about this query. Hopefully somebody can point me in the right direction.
I have two tables Person & Contact_No.
Person:
PersonID
Name
Sample Data:
1 John
2 Mary
3 Jeff
4 Ann
etc
Contact_No:
PersonID
Contact_Type
Number
Sample Data:
1 Cell 12345678
1 Home 98765432
1 Cell2 12458788
2 Home 23245453
3 Cell 11233434
3 Home 12546342
3 Home2 65445645
There is a set number of types; Cell, Cell2, Home, Home2.
The reltationship between the tables is One Person to ZeroMany Contact_No.
The query i want to run will have the following columns:
PersonID___Cell____Cell2____Home___Home2
1_________456456________45646_________
2_______________________987897________
3_________454210________132131__231300
4_____________________________________
The query should return all persons no matter if they have a contact no or not. The columns will contain all the 4 types.
Any ideas?
Thanks,
Sean