I have a query like this that will return two records, one with NULL in VendorCode and VendoroffsetAccount and another with valid values. I want a way to get the non null record if there are two records.Otherwise the record with NULL without using temp tables.Any help will be appreciated.
SELECT DISTINCT ift.BatchGuid AS ProcessId ,
'H' AS RecordType ,
ISNULL(ift.SuperBranch, cd.SuperBranch) AS SuperBranch ,
ISNULL(ift.ProcessName, cd.ProcessName) AS ProcessName ,
VendorOffsetAccount = CASE WHEN ift.OffsetType = 'V'
THEN ISNULL(ift.VendorOffsetAccount,
cd.VendorOffsetAccount)
END ,
VendorCode = CASE WHEN ift.OffsetType = 'V'
THEN ISNULL(ift.VendorCode, cd.VendorCode)
END
FROM IFP.InboundFileTransaction ift
CROSS APPLY IFP.ctlConfigDefault cd
WHERE CAST(BatchGuid AS CHAR(36)) = '67C6A9C3-F8B7-45ED-8DDD-0AB6701BED34'
Here is a sample output of this query.
Id Type SB Name VendorOffsetAccount VendorCode
1 H XYZ UPLOAD NULL NULL
1 H XYZ UPLOAD XYZ000123 DFEE
Thanks in Advance