lsgtechuser
Programmer
I use various different outer joins frequently, but for some reason i can't figure this out.
select y.lname,y.fname, count(distinct phone), count(distinct familyid)
from TownTbl x full outer join
(select distinct lname, fname from nametbl) y on x.lname= y.lname and x.fname= y.fname
where income = 'R'
AND 99 = 'Y'
group by y.lname,y.fname order by y.lname,y.fname
there are 1600 distinct lname and fnames
in nametbl (i've changed the names of the fields for the post) which would mean I should get exactly 1600 records back (unless i'm missing something obvious), but i get 1595. when i run the statements separately i get 1600 from one and 1595 for the other, i'm trying to combine the two and get null values in the count columns for instances which the where clause would exclude
I can't use a count(case ... statement here b/c i need to do count(distinct). any help would be appreciated, thanks in advance
select y.lname,y.fname, count(distinct phone), count(distinct familyid)
from TownTbl x full outer join
(select distinct lname, fname from nametbl) y on x.lname= y.lname and x.fname= y.fname
where income = 'R'
AND 99 = 'Y'
group by y.lname,y.fname order by y.lname,y.fname
there are 1600 distinct lname and fnames
in nametbl (i've changed the names of the fields for the post) which would mean I should get exactly 1600 records back (unless i'm missing something obvious), but i get 1595. when i run the statements separately i get 1600 from one and 1595 for the other, i'm trying to combine the two and get null values in the count columns for instances which the where clause would exclude
I can't use a count(case ... statement here b/c i need to do count(distinct). any help would be appreciated, thanks in advance