本文介绍了SQL CASE 语句的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有以下查询,我想将它们放在 sql CASE 语句中,因此我只有一个查询,但我不知道该怎么做.有人可以帮我吗?
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'
谢谢
推荐答案
UNION-Query 可能会有所帮助:
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'
这篇关于SQL CASE 语句的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!