SQL Question - Mailing list pgsql-novice

From Ketema Harris
Subject SQL Question
Date
Msg-id 983b67500602081143j3697b693s29ce5fc929e59fc0@mail.gmail.com
Whole thread Raw
Responses Re: SQL Question
SQL Query gone wrong.. please help
List pgsql-novice
Hey guys I have a SQL teaser I could use a little assistance with.
 
Imagine a table like below:
 
rowid|typeid|personid
---------------------------
1                3            1
2                3            1
3                1            2
4                1            1
5                3            2
 
my desired output is:
 
person|# of rows of type 3|# of total rows|% of type 3
----------------------------------------------------------------
1                            2                                    3                        66.7
2                            1                                    2                        50
 
how can I achieve this output with one single query?  sub selects are fine.
 
Thanks

pgsql-novice by date:

Previous
From: Noel Faux
Date:
Subject: data corruption how zero bad page blocks etc
Next
From: André de Camargo Fernandes
Date:
Subject: How to control memory usage of postgresql