SQL Question - Using Group By

Поиск
Список
Период
Сортировка
Искать
От
Mike
Тема
SQL Question - Using Group By
Дата
Msg-id
1172260251.135113.112560@j27g2000cwj.googlegroups.com
Список
Дерево обсуждения
SQL Question - Using Group By "Mike" <akiany@gmail.com>
Re: SQL Question - Using Group By "ksherlock@gmail.com" <ksherlock@gmail.com>
Re: SQL Question - Using Group By "Mike" <akiany@gmail.com>
Re: SQL Question - Using Group By Alban Hertroys <alban@magproductions.nl>
Re: SQL Question - Using Group By Tomas Vondra <tv@fuzzy.cz>
Hi,

I have a question about using Group By.

On a table like this:

Type (varchar)     |     Active (boolean)
--------------------------------------------------------
Type One           |      False
Type Two           |      True
Type One           |      True
Type Fifty           |      Flase
Type Two           |      True

Having this table I want a report grouping Types and giving me more
statistics such as:

Type    |    Active Count    |     Inactive Count    |    Active
Percent

How do i do that?

I can think of :

select Type from table_name group by Type

But that doesn't give me how many active and inactive each had!

Please help me here understand how to approach this.

Thank you,
Mike

В списке pgsql-general по дате отправления
От: Robert Haas
Дата:
От: Benjamin Arai
Дата:
FAQ