fegdvbna22
Programmer
How do I write some SQL which gives the result set for the records that are returned by one query and not returned by another query?
Here are my 2 queries :
1)select distinct ups.SerialNumber,
ups.Division,
ups.Family,
ups.Product,
ups.ContractStart,
ups.SAPContractNumber,
ups.ContractType,
ups.AccountNumber,
ups.Territory
from UploadDataStaging ups
2) select distinct ups.SerialNumber,
com.CompanySiteKey,
ups.Division,
ups.Family,
ups.Product,
ups.ContractStart,
ups.SAPContractNumber,
ups.ContractType,
ups.AccountNumber,
ups.Territory
from UploadDataStaging ups inner join CompanySite com on
ups.CustomerName = com.[Name]
where com.[name] = ups.CustomerName and com.Address1 = ups.Street1 and com.Address2 = ups.Street2
Here are my 2 queries :
1)select distinct ups.SerialNumber,
ups.Division,
ups.Family,
ups.Product,
ups.ContractStart,
ups.SAPContractNumber,
ups.ContractType,
ups.AccountNumber,
ups.Territory
from UploadDataStaging ups
2) select distinct ups.SerialNumber,
com.CompanySiteKey,
ups.Division,
ups.Family,
ups.Product,
ups.ContractStart,
ups.SAPContractNumber,
ups.ContractType,
ups.AccountNumber,
ups.Territory
from UploadDataStaging ups inner join CompanySite com on
ups.CustomerName = com.[Name]
where com.[name] = ups.CustomerName and com.Address1 = ups.Street1 and com.Address2 = ups.Street2