oracle - SQL sub query. Dont know how to start -


the table called people , has columns: id, fname, lname, state, jobtitle, salary, cat

i want display 50 states, number of people in state cat value of y, number of people in state cat value of n , total number of people in state. 4 column headings should state, yes, no , total.

i know supposed use sub queries not sure how begin.

here:

select upper(p.state) state,      (select count(*) people p2 p2.state = p.state , p2.cat = 'y') yes,      (select count(*) people p3 p3.state = p.state , p3.cat = 'n') no,      count(*) total people p group upper(state) 

if have doubt it, fell free ask.


Comments

Popular posts from this blog

php - Passing multiple values in a url using checkbox -

compilation - PHP install fails on Ubuntu 14 (make: *** [sapi/cli/php] Error 1) PHP 5.6.20 -

sql - Postgresql tables exists, but getting "relation does not exist" when querying -