Changes between Version 5 and Version 6 of AdvancedQueries


Ignore:
Timestamp:
08/27/25 10:41:42 (6 days ago)
Author:
221007
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • AdvancedQueries

    v5 v6  
    310310order by matching_diagnoses_count desc;
    311311}}}
     312
     313=== Пребарување на најдобрите 3 институции во изминатиот период од 1 година
     314
     315{{{
     316WITH top_3_institutions AS (
     317  SELECT ar.institution_id, COUNT(*) AS total_reports
     318  FROM report r
     319  JOIN academicreport ar ON ar.report_id = r.report_id
     320  WHERE r.created_at >= date_trunc('year', now()) - interval '1 year'
     321  GROUP BY ar.institution_id
     322  ORDER BY COUNT(*) DESC
     323  LIMIT 3
     324)
     325SELECT i.name, a.total_reports
     326FROM top_3_institutions a
     327JOIN institution i ON i.institution_id = a.institution_id
     328ORDER BY a.total_reports DESC;
     329}}}