我是Tableau的新手,希望/期待我可以从DB2导入SQL,以便在最初拉入并编译可视化。我有一个db2连接,然后转到自定义sql,但之后什么都没有加载。代码不是很复杂,但我确实有一些case语句。我尝试执行if语句,但这似乎没有给予我sql的功能。主要问题是,我需要从两个不同的日期提取一个字段,然后只显示这两个日期的不同结果。在Tableau中使用下面的查询是否可行?
SELECT
RMD.ISSUE_ID,
MAX(CASE WHEN AS_OF_DATE = '2021-08-15' THEN CURRENT.ISSUE_TITLE END) AS CURR_ISSUE_TITLE,
MAX(CASE WHEN AS_OF_DATE = '2021-08-15' THEN CURRENT.MEMBER_IMPACT END) AS CURR_MEMBER_IMPACT,
MAX(CASE WHEN AS_OF_DATE = '2021-08-08' THEN CURRENT.MEMBER_IMPACT END) AS PREV_MEMBER_IMPACT,
MAX(CASE WHEN AS_OF_DATE = '2021-08-15' THEN CURRENT.ISM_STATUS END) AS CURR_ISM_STATUS,
MAX(CASE WHEN AS_OF_DATE = '2021-08-15' THEN CURRENT.ISSUE_OWNER_ORG END) AS CURR_ISSUE_OWNER_ORG,
MAX(CASE WHEN AS_OF_DATE = '2021-08-15' THEN CURRENT.ISSUE_OWNER END) AS CURR_ISSUE_OWNER,
MAX(CASE WHEN AS_OF_DATE = '2021-08-15' THEN CURRENT.ISSUE_APPROVER END) AS CURR_ISSUE_APPROVER
FROM LOD.ISM_ISSUE_SUMMARY_HIST_WKY CURRENT INNER JOIN
LOD.RMD_ISS_REMED_SUMMARY RMD
ON CURRENT.ISSUE_ID = RMD.ISSUE_ID
WHERE AS_OF_DATE IN ('2021-08-08', '2021-08-15')
GROUP BY RMD.ISSUE_ID
HAVING MAX(CASE WHEN AS_OF_DATE = '2021-08-08' THEN CURRENT.MEMBER_IMPACT END) <> MAX(CASE WHEN AS_OF_DATE = '2021-08-15' THEN CURRENT.MEMBER_IMPACT END) ;
我试着写这个,但似乎没有做任何事情,因为它只是查询的一部分,或者我不知道如何完成它来完成完整的查询。
IF [As Of Date] = #2021-08-15# THEN [Issue Title] ELSEIF
[As Of Date] = #2021-08-15# THEN [Member Impact] ELSEIF
[As Of Date] = #2021-08-08# THEN [Member Impact] ELSEIF
[As Of Date] = #2021-08-015# THEN [Ism Status] ELSEIF
[As Of Date] = #2021-08-015# THEN [Issue Owner Org] ELSEIF
[As Of Date] = #2021-08-015# THEN [Issue Owner] ELSEIF
[As Of Date] = #2021-08-015# THEN [Issue Approver] END
是否可以直接在Tableau中引入我的查询?
1条答案
按热度按时间tvmytwxo1#
如果删除分号(“;“),查询会起作用吗?