| From: | Ketema Harris <ketema(at)gmail(dot)com> |
|---|---|
| To: | pgsql-novice(at)postgresql(dot)org |
| Subject: | SQL Question |
| Date: | 2006-02-08 19:43:24 |
| Message-ID: | 983b67500602081143j3697b693s29ce5fc929e59fc0@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | 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
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Jeffrey Melloy | 2006-02-08 20:32:44 | Re: SQL Question |
| Previous Message | Noel Faux | 2006-02-08 04:30:19 | data corruption how zero bad page blocks etc |