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