| От | Harry |
|---|---|
| Тема | aggregating into 2 dimensions? |
| Дата | |
| Msg-id | 20021207171034.2162120e.h3@x-maru.org обсуждение исходный текст |
| Список | pgsql-novice |
I'd like to perform a query that aggregates/counts based on 2 of my columns.
For example, with a table with 3 columns "date","dept","item", I'd like to get
counts of "item" grouped by "date" and "dept" so that I get a tablular result
such as:
date | deptA | deptB | deptC | ...
------------+------------------------------
2001-05-28 | 10 | 231 | 123 | ...
Basically, something like "select date,dept,count(item) from table group by
date,dept" except giving the results in 2 dimensions, with individual depts as
columns and perhaps a column for a total.
Is this something that can be done with basic SQL (without using functions)?
The number of depts is small and fixed, if that matters.
Thanks,
Harry
В списке pgsql-novice по дате отправления:
Сайт использует файлы cookie для корректной работы и повышения удобства. Нажимая кнопку «Принять» или продолжая пользоваться сайтом, вы соглашаетесь на их использование в соответствии с Политикой в отношении обработки cookie ООО «ППГ», в том числе на передачу данных из файлов cookie сторонним статистическим и рекламным службам. Вы можете управлять настройками cookie через параметры вашего браузера