Thank you!
This was what I was looking for!
Main Topics
Browse All TopicsHi Experts!
Hopefully someone is abel to help me with a SQL query
I have 2 tabels
Customers
id
Customerno
Lastname
Firstname
contrycode
data in Customers table
id,Customerno,Lastname,Fir
1,123456,'Doe','John',1
2,654321,'Smith','Jane',1
3,987456,'Brown','Jack',2
4,125468,'Black','Joe',1
Table Programs
id
customerid
level
ContryCode
Data in programs table
id,customerid,level,contry
1,1,3,1
2,1,1,1
3,1,7,1
4,3,1,2
5,4,1,1
6,4,1,1
7,4,1,1
8,4,2,1
9,4,1,1
What I am trying to accomplish is to pull all names from my customers table that have a level average higher than 1.3
and in addtion I would like to pull the names of those customers that have no rows in the programs table at all.
The query below:
select distinct(customerno),Lastn
where customers.contrycode=1
and (Select convert(float,sum(level))/
or (isnull((Select convert(float,sum(level))/
Gives me the result
123456,'Doe','John',1
What I would like is the result
123456,'Doe','John',1
654321,'Smith','Jane',1
Could someone be kind enough to show me how to get customers with no rows in programs table included in the result?
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Business Accounts
Answer for Membership
by: pivarPosted on 2009-10-03 at 07:41:21ID: 25485541
Hi,
ame,Firstn ame,contry code from customers count(prog rams.id) from programs where customers.id=programs.cust omerid)>=1. 3 omerid))
How about
select distinct(customerno),Lastn
where customers.contrycode=1
and ((Select convert(float,sum(level))/
or not exists (Select 1 from programs where customers.id=programs.cust
/peter