Hello,
I have created a sub query using the code below, but instead of recognising only the MPRs that are not null in GMS table when the GMS and IEU tables are joined, it just groups everything in the GMS table.
There are 45k records in the GMS table but only 34k that are also in the IEU table, it is the 34k that i want grouping by [companycode]?
OOch
I have created a sub query using the code below, but instead of recognising only the MPRs that are not null in GMS table when the GMS and IEU tables are joined, it just groups everything in the GMS table.
There are 45k records in the GMS table but only 34k that are also in the IEU table, it is the 34k that i want grouping by [companycode]?
Code:
SELECT GMS.CompanyCode, Count(GMS.MeterPointRef) AS Meters
FROM [A01-NBS_GAS_ROOTDATA_20040923] AS GMS
WHERE (Exists (SELECT *
FROM [B_04 Oct IEU Portfolio] AS IEU LEFT JOIN [A01-NBS_GAS_ROOTDATA_20040923] AS GMS1 ON IEU.[Mpo Reference (Result Object)] = GMS1.MeterPointRef
WHERE IEU.[Mpo Reference (ResultObject)] is not null))
GROUP BY GMS.CompanyCode;