Query is not working

raj08536

Active Member
Joined
Aug 16, 2007
Messages
322
Office Version
  1. 365
Platform
  1. Windows
I have two tables. One is 2nd Level AFDA and other InterCompany

2nd Level AFDA has 5 fields and Intercompany has two.

Both have SAPStrNo field comman. I want to join thes tables and ignore all the SAPStrNo records found in InterCompany. Following SQL query is not working.
I have 1206 records in 2nd Level AFDA and 22 records in Intercompany. Following Query generate 26531 records which definetly wrong because I expect less than 1206 records due to this query


SELECT [2nd Level AFDA].SAPStrNo, [2nd Level AFDA].StoreNo, [2nd Level AFDA].AccType, [2nd Level AFDA].Sortype, [2nd Level AFDA].Banner
FROM [2nd Level AFDA] where [2nd Level AFDA].SAPStrNo <> InterCompany.SAPStrNo;
 

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.
Hi

So you want all records in 2nd Level AFDA that has no match in Intercompany?

Code:
SELECT T1.SAPStrNo, T1.StoreNo, T1.AccType, T1.Sortype, T1.Banner
FROM [2nd Level AFDA] T1 LEFT JOIN Intercompany T2 On T1.SAPStrNo = T2.SAPStrNo WHERE T2.SAPStrNo Is Null;
 
Upvote 0

Forum statistics

Threads
1,215,054
Messages
6,122,897
Members
449,097
Latest member
dbomb1414

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top