Search Postgresql Archives

SQL Question - Using Group By

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux