sql-server - 在 View SQL server 中分组
问题描述
这是我创建的视图:
CREATE VIEW V_EventAnswers
AS
SELECT ISNULL(ROW_NUMBER() OVER (ORDER BY e.id DESC), -1) AS RowID,
ISNULL(Questionid, QuestionUniqueId) AS Questionid,
QuestionUniqueId,
QuestionNameAr,
QuestionNameEn,
QuestionType,
SectionId,
QuestionFieldOrder,
QuestionAnswers,
IsIssue,
QuestionUnit,
ReadinessIndicator,
e.id AS EventId,
e.SubmitionDate,
e.Location,
e.TenantId
FROM EventDetails D
CROSS APPLY
OPENJSON(D.SubmittedJSONDATA)
WITH (questions nvarchar(MAX) '$.fields' AS json) AS jsonValues
OUTER APPLY
openjson(questions)
WITH (IsIssue bit '$.issue',
QuestionUnit int '$.responsibleUnit',
QuestionUniqueId nvarchar(100) '$.id',
Questionid nvarchar(100) '$.templateQuestionId',
QuestionNameAr nvarchar(100) '$.arLabel',
QuestionNameEn nvarchar(100) '$.enLabel',
QuestionType nvarchar(100) '$.controlType',
SectionId nvarchar(100) '$.sectionId',
QuestionFieldOrder int '$.fieldOrder',
ReadinessIndicator int '$.readinessIndicator',
answers nvarchar(MAX) '$.values' AS json) AS jsonAnswers
OUTER APPLY
openjson(answers)
WITH (QuestionAnswers nvarchar(MAX) '$')
INNER JOIN EVENT E ON E.id = D.EventId;
GO
我需要对questions
部件进行分组,'$.id'
并在逗号分隔的列表中EventId
获取id`。answers``forf every
我尝试了太多解决方案但没有输出
解决方案
推荐阅读
- java - 如何在 onClick 事件和 Activity 更改后将 textView 设置为可见?
- azure - 跟踪 Azure DevOps 构建活动
- ruby-on-rails - 将日期字符串转换为时区特定格式
- email - google 应用程序脚本:file.setOwner() 未在 Google Drive 中转移所有权
- c# - 如何从查看 http post 将列表模型传递给控制器
- google-apps-script - 谷歌表格以模态嵌入谷歌表单
- c# - MVVM - 如何从父 ViewModel 引用子 ViewModel(ViewModel 在其视图中创建)?
- javascript - How to rotate an arc in canvas using context?
- java - 如果java中的字符串是不可变的,为什么我可以这样做?
- python - 尝试从 Mac 上的终端打开 Python3