Answer the question
In order to leave comments, you need to log in
Query with COUNT function with monthly breakdown?
Guys, good afternoon, I
need help with a SELECT query
, there is a table with reports:
create table new_1report
(
id_report serial not null
constraint new_1report_pkey
primary key,
id_form integer
constraint new_1report_id_form_fkey
references new_form,
admin varchar(40),
created_at timestamp default now(),
);
fio Jan Feb Mar
Ivanov I 5 3 8
Petrov A 7 10 13
....
SELECT COUNT(admin_id), admin_id, a.admname
FROM new_1report f
JOIN admin a ON f.admin_id = a.id
group by admin_id, a.admname
Answer the question
In order to leave comments, you need to log in
You can do this, and then parse it on the application side
SELECT COUNT(admin_id), admin_id, a.admname, date_part('month', f.created_at)
FROM new_1report f
JOIN admin a ON f.admin_id = a.id
group by admin_id, a.admname, date_part('month', f.created_at)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question