Advertisement
Guest User

Untitled

a guest
Apr 3rd, 2019
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
T-SQL 0.58 KB | None | 0 0
  1. SELECT "P"."Id" "PatientId"
  2. FROM "Patient" "P"
  3. INNER JOIN (
  4.     SELECT
  5.         "_PPFIS".*,
  6.         "_PP"."PatientId" "PatientId"
  7.     FROM "ProcessPatientFamilyIncomeStatement" "_PPFIS"
  8.     INNER JOIN "ProcessPatient" "_PP" ON "_PP"."Id" = "_PPFIS"."ProcessPatientId"
  9.     WHERE "_PPFIS"."Id" = (
  10.         SELECT TOP 1"__PPFIS"."Id"
  11.         FROM "ProcessPatientFamilyIncomeStatement" "__PPFIS"
  12.         INNER JOIN "ProcessPatient" "__PP" ON "__PP"."Id" = "__PPFIS"."ProcessPatientId"
  13.         WHERE "__PP"."PatientId" = "_PP"."PatientId"
  14.         ORDER BY "__PPFIS"."LastUpdateDate" DESC
  15.     )
  16. ) "PPFIS" ON "PPFIS"."PatientId" = "P"."Id"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement