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
Post a Comment