Teradata 查询中的多个Case语句

Teradata 查询中的多个Case语句,teradata,Teradata,你能告诉我为什么这句话是错的吗?它给了我一个错误,它期待的是别的东西而不是案例短语 SELECT ACT.Employee_Id, case when max( case when not ACT.ActivityTime_Date like '2019-09-%' and ACT.Activity_Time_Date not like '09/%/2019' and not (ACT.Action like 'ACTIVITY_create_%'

你能告诉我为什么这句话是错的吗?它给了我一个错误,它期待的是别的东西而不是案例短语


      SELECT  ACT.Employee_Id, 
      case  when max( case when not ACT.ActivityTime_Date like '2019-09-%' and ACT.Activity_Time_Date not like '09/%/2019' and 
      not (ACT.Action like 'ACTIVITY_create_%' or ACT.Action like 'ACTIVITY_update_%') and
       not ACT.Destination_ObjectType in ('announcement', 'attachment'
      ,'blog','blogpost','community', 'directmessage', 'document', 'event', 'idea', 'message', 'poll', 'project', 'question',
      'socialgroup', 'task', 'thread', 'video', 'wallentry')) then 1 else 0 
      END)=0
      then 'Contributor'
       from Analytics.ConnectTodayActive ACT;

这就是错误所在

SQL Editor 1: Encountered "case when max ( case when not ( ACT . ActivityTime_Date like \'2019-09-%\' or ACT . ActivityTime_Date like \'09/%/2019\' ) and not ( ACT . Action like not.
Was expecting one of:
    "column" ...
    "row" ...
    "transactiontime" ...
    "validtime" ...
    "(" ...
    "until_changed" ...
    "until_closed" ...
    <NAME> ...
    "sampleid" ...
    "interval" ...
    "date" ...
    "time" ...
    "timestamp" ...
    "begin" ...
    "end" ...
    "next" ...
    <SINGLE_STRING_LITERAL> ...
    <INTEGER_LITERAL> ...
    <FLOATING_POINT_LITERAL> ...
    ":" ...
    "?" ...
    <NAMED_QUESTIONMARK> ...
    "@" ...
    "null" ...
    "user" ...
    "current_role" ...
    "current_user" ...
    "session" ...
    "account" ...
    "database" ...
    "role" ...
    "profile" ...
    "zone" ...
    "td_host" ...
    "td_authid" ...
    "new" ...
    "current_date" ...
SQL编辑器1:遇到“最大值时的大小写(非最大值时的大小写(如'2019-09-%\'或'09/%/2019\'时的ACT.ActivityTime\'日期)和非最大值时的大小写(如'09/%/2019\'时的ACT.Action)。
我期待的是:
“专栏”。。。
“行”。。。
“交易时间”。。。
“有效时间”。。。
"(" ...
“直到你改变”。。。
“直到你关门”。。。
...
“样本”。。。
“间隔”。。。
“日期”。。。
“时间”。。。
“时间戳”。。。
“开始”。。。
“结束”。。。
“下一个”。。。
...
...
...
":" ...
"?" ...
...
"@" ...
“空”。。。
“用户”。。。
“当前_角色”。。。
“当前用户”。。。
“会议”。。。
“帐户”。。。
“数据库”。。。
“角色”。。。
“个人资料”。。。
“区域”。。。
“td_主机”。。。
“td_authid”。。。
“新的”。。。
“当前日期”。。。

您的查询似乎格式不正确:

  • 您的外部
    案例
    语句缺少
    结尾
  • 结束括号不合适
  • 如果您想返回
    employee\u id
    ,您需要使用
    groupby
    ,因为您使用的是
    MAX
您也应该能够组合您的
LIKE
条件,因此如下所示:

选择
雇员身份证,
案例
当马克斯(
案例
什么时候
ACT.ActivityTime_日期与所有日期不同('2019-09-%'、'09/%/2019'),以及
Action.Action不象ALL('ACTIVITY\u create\u%'、'ACTIVITY\u update\u%')和
ACT.Destination_ObjectType不在('announcement'、'attachment'、'blog'、'blogpost'、'community'、'directmessage'、'document'、'event'、'idea'、'message'、'poll'、'project'、'question'、'socialgroup'、'task'、'thread'、'video'、'wallength')
那么1
其他0
结束
)=0,则为“参与者”
以我的名字结束
来自Analytics.ConnectTodayActive ACT
按ACT.Employee\u Id分组;

您的查询似乎格式不正确:

  • 您的外部
    案例
    语句缺少
    结尾
  • 结束括号不合适
  • 如果您想返回
    employee\u id
    ,您需要使用
    groupby
    ,因为您使用的是
    MAX
您也应该能够组合您的
LIKE
条件,因此如下所示:

选择
雇员身份证,
案例
当马克斯(
案例
什么时候
ACT.ActivityTime_日期与所有日期不同('2019-09-%'、'09/%/2019'),以及
Action.Action不象ALL('ACTIVITY\u create\u%'、'ACTIVITY\u update\u%')和
ACT.Destination_ObjectType不在('announcement'、'attachment'、'blog'、'blogpost'、'community'、'directmessage'、'document'、'event'、'idea'、'message'、'poll'、'project'、'question'、'socialgroup'、'task'、'thread'、'video'、'wallength')
那么1
其他0
结束
)=0,则为“参与者”
以我的名字结束
来自Analytics.ConnectTodayActive ACT
按ACT.Employee\u Id分组;

你的问题到
错误全文你的问题到
错误全文