Changes between Version 13 and Version 14 of AdvancedReports


Ignore:
Timestamp:
01/09/23 22:17:39 (2 years ago)
Author:
201063
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • AdvancedReports

    v13 v14  
    66{{{#!sql
    77select
    8         shelter.id_shelter,
    9         shelter.name_shelter,
    10         shelter.email_shelter,
    11         shelter.telephone_shelter,
    12         avg(adopters_verified) as average_verified_adopters
    13 from
    14         shelter
    15 left join
     8    sh.id_shelter,
     9    sh.name_shelter,
     10    sh.email_shelter,
     11    sh.telephone_shelter,
     12    org.name_organisation,
     13    q2.average_verified_adopters
     14from
    1615        (
    17                 select
    18                         employee.id_user as employee_id,
    19                         employee.id_shelter as shelter_id,
    20                         count(distinct adopter.id_user) as adopters_verified
     16                select
     17                        shelter.id_shelter,
     18                        avg(adopters_verified) as average_verified_adopters
    2119                from
    22                         employee
    23                 join adopter
    24                         on adopter.verified_by_employee = employee.id_user
     20                        shelter
     21                left join
     22                        (
     23                                select
     24                                        employee.id_user as employee_id,
     25                                        employee.id_shelter as shelter_id,
     26                                        count(distinct adopter.id_user) as adopters_verified
     27                                from
     28                                        employee
     29                                join adopter
     30                                        on adopter.verified_by_employee = employee.id_user
     31                                group by
     32                                        employee.id_user
     33                        ) as q1
     34                        on q1.shelter_id = shelter.id_shelter
    2535                group by
    26                         employee.id_user
    27         ) as q1
    28         on q1.shelter_id = shelter.id_shelter
    29 group by
    30         shelter.id_shelter
    31 order by
    32         average_verified_adopters desc
     36                        shelter.id_shelter
     37                order by
     38                        average_verified_adopters desc
     39        ) as q2
     40               
     41join shelter as sh
     42        on sh.id_shelter = q2.id_shelter
     43
     44join organisation as org
     45        on org.id_organisation = sh.id_organisation
    3346}}}
    3447