jangleejat
Technical User
In the following query I only get rows returned when a person has friends. I also want to get names and addresses for people who have no friends with a 0 in the result for friends. Problem is that it has to be db independent. If anyone can solve it, please also put in explanation for the logic if you have time.
Select PEOPLE.name,
CONTACTS.address,
Count( distinct FRIENDS.friends_id)
From
PEOPLE,
CONTACTS,
MYGROUP,
FRIENDS
Where CONTACTS.user_ID in (select distinct CONTACTS.user_id from CONTACTS where .....)
And PEOPLE.user_id = CONTACTS.user_id
And MYGROUP.group_id = CONTACTS.group_id
And MYGROUP.some-id = 1
And FRIENDS.user_id = CONTACTS.user_id
group by PEOPLE.name, CONTACTS.address
The expected result is
Name Address Number of Friends
Mary 123 My St. 3
Jaya 453 Stone. 2
Mina 2 Terrace. 0
Currently Mina does not show up because she has no friends ;-)
Select PEOPLE.name,
CONTACTS.address,
Count( distinct FRIENDS.friends_id)
From
PEOPLE,
CONTACTS,
MYGROUP,
FRIENDS
Where CONTACTS.user_ID in (select distinct CONTACTS.user_id from CONTACTS where .....)
And PEOPLE.user_id = CONTACTS.user_id
And MYGROUP.group_id = CONTACTS.group_id
And MYGROUP.some-id = 1
And FRIENDS.user_id = CONTACTS.user_id
group by PEOPLE.name, CONTACTS.address
The expected result is
Name Address Number of Friends
Mary 123 My St. 3
Jaya 453 Stone. 2
Mina 2 Terrace. 0
Currently Mina does not show up because she has no friends ;-)