WHEN声明接着何时声明

时间:2015-10-06 18:17:34

标签: sql events

我正在尝试使用double when语句但不确定如何执行此操作。 这是我正在使用的代码

CASE WHEN dbo.CSEFExtWorkflowAbsences.Number41=1 THEN dbo.CSEFExtWorkflowAbsences.Text1
WHEN dbo.CSEFExtWorkflowAbsences.Number41=2 THEN dbo.CSEFExtWorkflowAbsences.Text2
WHEN dbo.CSEFExtWorkflowAbsences.Number41=3 THEN dbo.CSEFExtWorkflowAbsences.Text3
WHEN dbo.CSEFExtWorkflowAbsences.Number41=4 THEN dbo.CSEFExtWorkflowAbsences.Text4
WHEN dbo.CSEFExtWorkflowAbsences.Number41=5 THEN dbo.CSEFExtWorkflowAbsences.Text5
WHEN dbo.CSEFExtWorkflowAbsences.Number41=6 THEN dbo.CSEFExtWorkflowAbsences.Text6
WHEN dbo.CSEFExtWorkflowAbsences.Number41=7 THEN dbo.CSEFExtWorkflowAbsences.Text7
WHEN dbo.CSEFExtWorkflowAbsences.Number41=8 THEN dbo.CSEFExtWorkflowAbsences.Text8
WHEN dbo.CSEFExtWorkflowAbsences.Number41=9 THEN dbo.CSEFExtWorkflowAbsences.Text9
WHEN dbo.CSEFExtWorkflowAbsences.Number41=10 THEN dbo.CSEFExtWorkflowAbsences.Text10
WHEN dbo.CSEFExtWorkflowAbsences.Number41=11 THEN dbo.CSEFExtWorkflowAbsences.Text11
WHEN dbo.CSEFExtWorkflowAbsences.Number41=12 THEN dbo.CSEFExtWorkflowAbsences.Text12
WHEN dbo.CSEFExtWorkflowAbsences.Number41=13 THEN dbo.CSEFExtWorkflowAbsences.Text13
WHEN dbo.CSEFExtWorkflowAbsences.Number41=14 THEN dbo.CSEFExtWorkflowAbsences.Text14
WHEN dbo.CSEFExtWorkflowAbsences.Number41=15 THEN dbo.CSEFExtWorkflowAbsences.Text15
WHEN dbo.CSEFExtWorkflowAbsences.Number41=16 THEN dbo.CSEFExtWorkflowAbsences.Text16
WHEN dbo.CSEFExtWorkflowAbsences.Number41=17 THEN dbo.CSEFExtWorkflowAbsences.Text17
WHEN dbo.CSEFExtWorkflowAbsences.Number41=18 THEN dbo.CSEFExtWorkflowAbsences.Text18
WHEN dbo.CSEFExtWorkflowAbsences.Number41=19 THEN dbo.CSEFExtWorkflowAbsences.Text19
WHEN dbo.CSEFExtWorkflowAbsences.Number41=20 THEN dbo.CSEFExtWorkflowAbsences.Text20
ELSE 'N/A' END

我没有考虑到的是dbo.CSEFExtWorkflowAbsences.Text[xx]可以为null我想要做的是在WHEN之后的每个THEN语句中我会使用另一个WHEN ISNULL ELSE写“看到附件”isnull使用文本if not not null。不确定如何写入。当我尝试when isnullcase when isnullelse后跟controller as alias时,请继续关注。

3 个答案:

答案 0 :(得分:5)

为什么不isnull周围的case?您也可以使用case的形式选择值而不是条件:

ISNULL(CASE dbo.CSEFExtWorkflowAbsences.Number41
  WHEN 1 THEN dbo.CSEFExtWorkflowAbsences.Text1
  WHEN 2 THEN dbo.CSEFExtWorkflowAbsences.Text2
  WHEN 3 THEN dbo.CSEFExtWorkflowAbsences.Text3
  WHEN 4 THEN dbo.CSEFExtWorkflowAbsences.Text4
  WHEN 5 THEN dbo.CSEFExtWorkflowAbsences.Text5
  WHEN 6 THEN dbo.CSEFExtWorkflowAbsences.Text6
  WHEN 7 THEN dbo.CSEFExtWorkflowAbsences.Text7
  WHEN 8 THEN dbo.CSEFExtWorkflowAbsences.Text8
  WHEN 9 THEN dbo.CSEFExtWorkflowAbsences.Text9
  WHEN 10 THEN dbo.CSEFExtWorkflowAbsences.Text10
  WHEN 11 THEN dbo.CSEFExtWorkflowAbsences.Text11
  WHEN 12 THEN dbo.CSEFExtWorkflowAbsences.Text12
  WHEN 13 THEN dbo.CSEFExtWorkflowAbsences.Text13
  WHEN 14 THEN dbo.CSEFExtWorkflowAbsences.Text14
  WHEN 15 THEN dbo.CSEFExtWorkflowAbsences.Text15
  WHEN 16 THEN dbo.CSEFExtWorkflowAbsences.Text16
  WHEN 17 THEN dbo.CSEFExtWorkflowAbsences.Text17
  WHEN 18 THEN dbo.CSEFExtWorkflowAbsences.Text18
  WHEN 19 THEN dbo.CSEFExtWorkflowAbsences.Text19
  WHEN 20 THEN dbo.CSEFExtWorkflowAbsences.Text20
  ELSE 'N/A'
END, 'See attachment')

答案 1 :(得分:2)

只需进行ISNULL()检查。

ionic run android

答案 2 :(得分:0)

为什么不再添加一个声明?

jackson-annotations

这样可以正常工作。