Re: Question re 2 aggregates from 1 query
| От | Chris Spotts |
|---|---|
| Тема | Re: Question re 2 aggregates from 1 query |
| Дата | |
| Msg-id | 009b01c9f03e$e9150fc0$bb3f2f40$@com обсуждение исходный текст |
| Ответ на | Question re 2 aggregates from 1 query (Scott Ribe <scott_ribe@killerbytes.com>) |
| Ответы |
Re: Question re 2 aggregates from 1 query
|
| Список | pgsql-general |
> > Is there any way to get count of docs & pages imported by date without > resorting to selecting from a select: [Spotts, Christopher] If I understand you correctly..? create table docs (id int8 primary key, imported_when timestamp ); create table pages (id int8 primary key, doc_id int8 not null references docs); INSERT INTO docs values (1,now()),(2,now()),(3,now()),(4,now()- interval '1 day'); INSERT INTO pages values (1,1),(2,1),(3,2),(4,2),(5,3),(6,4),(7,4),(8,4); select imported_when::date, count(distinct pages.id),count(distinct docs.id) from docs, pages where docs.id = pages.doc_id group by imported_when::date;
В списке pgsql-general по дате отправления: