views:

83

answers:

1

Hi Friends, I have the following queries and I want to put them in an sql CASE statement so I would have only one query but I don't know how to do that. Can somebody help me?

IF (SELECT EtlLoadId 
 FROM  ssislogs.audit.processcontrol 
 WHERE SubjectArea = 'UaqaFacetsImp') > 0
SELECT pc.SrcFileName + ' - '+  CONVERT(VARCHAR(10), pc.[RecordCount] ) AS FacetsImpCount
 FROM  ssislogs.audit.processcontrol pc left outer join
 Uaqa.LettersAndCardsExports lc
on pc.etlloadid = lc.etlloadid
  WHERE pc.subjectarea = 'UaqaFacetsImp'
ELSE
SELECT 'No input file' AS FacetsImpCount

SELECT pc.subjectarea AS FacetsRjctFile
FROM  ssislogs.audit.processcontrol pc left outer join
Uaqa.LettersAndCardsExports lc
on pc.etlloadid = lc.etlloadid
  WHERE pc.subjectarea = 'UaqaFacetsRjct'

SELECT pc.subjectarea AS FacetsPvsFile
FROM  ssislogs.audit.processcontrol pc left outer join
Uaqa.LettersAndCardsExports lc
on pc.etlloadid = lc.etlloadid
  WHERE pc.subjectarea = 'UaqaFacetsPvs'

Thanks

+1  A: 

Propably a UNION-Query will help:

SELECT  'FacetsRjctFile' as Type, pc.subjectarea
FROM  ssislogs.audit.processcontrol pc left outer join
Uaqa.LettersAndCardsExports lc
on pc.etlloadid = lc.etlloadid
  WHERE pc.subjectarea = 'UaqaFacetsRjct'

UNION

SELECT 'FacetsPvsFile' as Type, pc.subjectarea
FROM  ssislogs.audit.processcontrol pc left outer join
Uaqa.LettersAndCardsExports lc
on pc.etlloadid = lc.etlloadid
  WHERE pc.subjectarea = 'UaqaFacetsPvs'
Ice