尝试使用CASE语句根据不同的条件更新几列。但我没有看到专栏正在更新。当做一个SELECT时,CASE工作得非常好。下面是单列失败的示例更新语句。
UPDATE D
SET EnglandOrWales = CASE WHEN Name = 'crnDeathOccurredInEnglandOrWales'
THEN C.Data ELSE D.EnglandOrWales END
FROM @CorDeaths D
INNER JOIN CustomFieldData C
ON C.EntityId = D.EntityID
INNER JOIN MetaData.MetaDataCustomField M
ON C.MetaDataCustomFieldUId = M.MetaDataCustomFieldUId
WHERE
MetaDataAttributeHierarchyGroupId IN (50, 53)
下面的SELECT工作正常并且在没有匹配的地方返回NA并返回C.Data以匹配记录。
SELECT
CASE WHEN Name = 'crnDeathOccurredInEnglandOrWales'
THEN C.Data ELSE 'NA' END
FROM @CorDeaths D
INNER JOIN CustomFieldData C
ON C.EntityId = D.EntityID
INNER JOIN MetaData.MetaDataCustomField M
ON C.MetaDataCustomFieldUId = M.MetaDataCustomFieldUId
WHERE
MetaDataAttributeHierarchyGroupId IN (50, 53)
答案 0 :(得分:0)
尝试分开更新并添加CASE的位置:
library(htmlwidgets)
sn <- sankeyNetwork(Links = links, Nodes = nodes,
Source = "source", Target = "target",
Value = "value", NodeID = "name",
fontSize = 12, nodeWidth = 30)
clickJS <- 'd3.selectAll(".link").on("click", function(d){ alert(d.value); })'
htmlwidgets::onRender(sn, clickJS)