Solved

SQL 2005 Left join

Posted on 2008-06-24
2
584 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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

There are some very powerful Data Management Views (DMV's) introduced with SQL 2005. The two in particular that we are going to discuss are sys.dm_db_index_usage_stats and sys.dm_db_index_operational_stats.   Recently, I was involved in a discu…
I've encountered valid database schemas that do not have a primary key.  For example, I use LogParser from Microsoft to push IIS logs into a SQL database table for processing and analysis.  However, occasionally due to user error or a scheduled task…
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…

635 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