Advertisement
suburg

Untitled

Aug 11th, 2022
28
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. SELECT
  2. v.root_guid AS drso_guid,
  3. MAX(cancellation_date) AS cancellation_date,
  4. COUNT(DISTINCT house_code) AS house_count
  5. FROM
  6. agrsm.agr_rso_documents v
  7. INNER JOIN agrsm.agr_rso_houses rso_houses ON v.root_guid = rso_houses.agreement_guid
  8. WHERE
  9. v.cancellation_date IS NOT NULL
  10. AND v.cancellation_date BETWEEN '2022-07-25'::date AND '2022-08-04'::date
  11. AND v.version BETWEEN rso_houses.lo_doc_version AND rso_houses.hi_doc_version
  12. GROUP BY
  13. v.root_guid
  14. ORDER BY
  15. COUNT(DISTINCT house_code) DESC;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement