Skip to content

Instantly share code, notes, and snippets.

@meanother
Created October 14, 2021 19:21
Show Gist options
  • Select an option

  • Save meanother/dbf0acc380fa71ee0d5e8d711b9ea061 to your computer and use it in GitHub Desktop.

Select an option

Save meanother/dbf0acc380fa71ee0d5e8d711b9ea061 to your computer and use it in GitHub Desktop.
select
substr(create_dt::varchar,1,7) as month
, round(avg(score), 1) as "Среднее"
, trunc(median(score)) as "Медиана"
, count(*) as "Общее кол-во"
, sum(case when score = 1 then 1 else 0 end) as "Оценка 1"
, sum(case when score = 2 then 1 else 0 end) as "Оценка 2"
, sum(case when score = 3 then 1 else 0 end) as "Оценка 3"
, sum(case when score = 4 then 1 else 0 end) as "Оценка 4"
, sum(case when score = 5 then 1 else 0 end) as "Оценка 5"
, sum(case when score is null then 1 else 0 end) as "Без оценки"
from
home.dt_banki_responses
where
date(create_dt) >= '2021-01-01'
group by substr(create_dt::varchar,1,7)
order by substr(create_dt::varchar,1,7) asc;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment