Solved

SQL 2005 Left join

Posted on 2008-06-24
2
577 Views
Last Modified: 2010-05-18
I have a query that is similar to the one below.  I am trying to get all the records from tableA but the where clause is removing the records. I want the records that do not exists in the table b to be null.
select max(cola)
from tableA
left join tableB on tableB.colB = tableA.colB
where tableA.colA<table.colB
group by tableA.colA

Open in new window

0
Comment
Question by:yanci1179
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 500 total points
ID: 21855455
change:
select max(cola)
from tableA
left join tableB on tableB.colB = tableA.colB AND tableA.colA<table.colB
group by tableA.colA

Open in new window

0
 
LVL 43

Expert Comment

by:TimCottee
ID: 21855464
Hello yanci1179,

1:   select max(cola)
2:   from tableA
3:   left join tableB on tableB.colB = tableA.colB
4:   where tableA.colA<tableB.colB Or tableB.colB Is Null
5:   group by tableA.colA

Regards,

TimCottee
0

Featured Post

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

In SQL Server, when rows are selected from a table, does it retrieve data in the order in which it is inserted?  Many believe this is the case. Let us try to examine for ourselves with an example. To get started, use the following script, wh…
In this article I will describe the Backup & Restore method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question