Changes between Version 5 and Version 6 of AdvancedReports


Ignore:
Timestamp:
01/31/22 19:51:29 (2 years ago)
Author:
191151
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • AdvancedReports

    v5 v6  
    5858}}}
    5959
     60== Популарни артисти - рангирано според број на рецензии, тотална заработка и број на добиени понуди
     61
     62{{{#!sql
     63select
     64        u.full_name,
     65        u.email,
     66        a.city,
     67        a.country,
     68        a.price_per_hour,
     69        at2.name,
     70        coalesce(sum(t.stripe_price),0) as earnings,
     71        (
     72                select
     73                        count(o2.id)
     74                from offers o2
     75                where o2.artist_id = a.user_id
     76        ) as num_offers,
     77        (
     78                (5 * (select
     79                        count(re.artist_id)
     80                        from reviews re
     81                        where
     82                                re.rating = 5 and
     83                                re.artist_id = a.user_id) +
     84                4 * (select
     85                        count(re.artist_id)
     86                        from reviews re
     87                        where
     88                                re.rating = 4 and
     89                                re.artist_id = a.user_id) +
     90                3 * (select
     91                        count(re.artist_id)
     92                        from reviews re
     93                        where
     94                                re.rating = 3 and
     95                                re.artist_id = a.user_id) +
     96                2 * (select
     97                        count(re.artist_id)
     98                        from reviews re
     99                        where
     100                                re.rating = 2 and
     101                                re.artist_id = a.user_id) +
     102                1 * (select
     103                        count(re.artist_id)
     104                        from reviews re
     105                        where
     106                                re.rating = 1 and
     107                                re.artist_id = a.user_id)) /
     108                ((select
     109                        count(re.artist_id)
     110                        from reviews re
     111                        where
     112                                re.artist_id = a.user_id))
     113        )
     114        as average_rating
     115from users u
     116join artists a on
     117        a.user_id = u.id
     118join artist_types at2 on
     119        at2.id = a.artist_type_id
     120left join reviews r on
     121        r.artist_id = a.user_id
     122left join offers o on
     123        o.artist_id = a.user_id
     124left join transactions t on
     125        t.offer_id = o.id
     126group by a.user_id, u.id, at2.id
     127order by
     128        average_rating desc,
     129        earnings desc,
     130        num_offers asc;
     131}}}
     132
    60133== Број на барања испратени кон одреден артист за одреден настан.
    61134