【发布时间】:2017-02-02 14:49:52
【问题描述】:
我有这样的记录:
我想查询并返回这样的报告结果(没有任何可用的 BI 工具,仅使用 SSMS):
我试过了:
select distinct A.Document_Title, A.First_Reviewer, A.Second_Reviewer, A.Third_Reviewer,
(select B.First_review from View as B where B.Title = A.Title) as First_Review,
(select B.Second_review from View as B where B.Title = A.Title) as Second_Review,
(select B.Third_review from View as B where B.Title = A.Title) as Third_Review
From
View A
我收到错误,因为我的子查询返回多个结果,我也尝试使用 Coalesce,但意识到它用于组合多个列。 任何帮助表示赞赏。谢谢。
【问题讨论】:
-
我根据证据优势删除了plsql标签。
-
这里使用的逻辑有点好奇。我会复制该视图,并对其进行编辑以准确返回您想要的内容。
标签: sql sql-server tsql reporting