-1

需要有关如何使用以下模式使用 JSON 路径表达式制作EmailId子数组的指导:EventId

http://sqlfiddle.com/#!6/8f8ecc/2

4

1 回答 1

0

你可以使用这个。

DECLARE @PatientId INT = 1

SELECT Event.*, RE.EmailId 
FROM ( SELECT DISTINCT
          E.EventId,
          E.StartDate,
          E.EndDate,
          E.IsRecurring,
          MRP.RecurringPatternId,
          MRP.MedicationId,
          PMR.PatientId
      FROM 
        Event E
        INNER JOIN MedicationRecurringPattern MRP ON E.EventId = MRP.EventId
        INNER JOIN PatientMedicationReminders PMR ON E.EventId = PMR.EventId
      WHERE 
        PMR.PatientId = @PatientId
    ) Event
  LEFT JOIN ReminderEmails RE ON Event.EventId = RE.EVentId
  LEFT JOIN Email ON RE.EmailId = Email.EmailId
 FOR JSON AUTO
于 2017-10-10T20:21:20.307 回答