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

java - nested exception is org.hibernate.exception.SQLGrammarException: could not extract ResultSet Hibernate+SpringMVC -

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

asp.net mvc - breakpoint on javascript in CSHTML? -