i spent around 4 hours on this but i couldnt find answer, i want the result like
Rejects
somefilename1.txt – Rejected (and if no file then No from else expression(No – Invalid) – Query 1)
somefilename2.txt – Previous (and if no file then No from else expression(No – Valid) -Query 2)
I dont understand what do i do, do i use union all or case expression. plz help me with this.
QUERY1:
if exists (select NULL from table1 where Column1 = 'File1')
select distinct Column1 +'-'+ 'Rejected' as 'Rejects' from table1
where Column1 = 'File1'
else
select 'No' as 'Invalid'
QUERY2:
if exists (select NULL from table1 where Column1 = 'File2')
select distinct Column1 +'-'+ 'Previous' as 'Rejects' from table1
where column1 = 'File2'
else
select 'No' as 'valid'
Thanks
Base on comments, see if this returns what you’re looking for.
If there are no records in the table the result is
No Input FileWhen records are present, each row is evaluated with the
CASEstatement.This
IFreturns this: