September 5, 2006 at 7:30 am
Hello,
I expose you a problem
I have n customers c1,c2,cn
Each of these customers can have n profils P1, P2, Pn
I have a table ref like
ex:
Profil |
---------
P1
P2
P3
My customers table is actualy like (exemple for 3 cust and 3 profils), i can have n values for each CustId/Profil
CustID | Profil | Value
-----------------------
c1 | P1 | 12
c1 | P1 | 45
c1 | P2 | 78
c1 | P2 | 35
c2 | P3 | 87
c2 | P3 | 45
c2 | P3 | 68
c3 | P1 | 73
Now what i want to do is to create a table with a line for for each value of a cust and for each profil.
So the the result is:
CustID | Profil | Value
-----------------------
c1 | P1 | 12
c1 | P1 | 45
c1 | P2 | 78
c1 | P2 | 35
c1 | P3 | NULL
c1 | P3 | NULL
c2 | P1 | NULL
c2 | P1 | NULL
c2 | P1 | NULL
c2 | P2 | NULL
c2 | P2 | NULL
c2 | P2 | NULL
c2 | P3 | 87
c2 | P3 | 45
c2 | P3 | 68
c3 | P1 | 73
c3 | P2 | NULL
c3 | P3 | NULL
I test many jointure but i don't solve this problem.
Thanks for your help !
September 5, 2006 at 8:06 am
Try Full outer join, something like
select * from customers full outer join profile
on customers.custid = profile.custid
Kindest Regards,
Sameer Raval [Sql Server DBA]
Geico Insurance
RavalSameer@hotmail.com
September 5, 2006 at 9:19 am
Thanks for answer, I find the issue by using cross join and full outer join
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply