Link to home
Start Free TrialLog in
Avatar of jmichael18
jmichael18

asked on

help with SQL conditional report

i have a table (stacked) with variables cipcode, awlevel, unitid, and year.  

im trying to generate a report that will tell me the distinct count of unitid where awlevel=5 and cipcode=45.0601 in 2001 but not 2011.  Basically i need results where cipcode only exists when year=2001 and doesnt exist when year=2011.

so far i have this, which gives me the results for 2001 only
	select count(distinct(unitid)) as Grad11 label="Schools with Graduations",
	from stacked
	where awlevel=5 and cipcode='45.0601' and year=2001;

Open in new window


I think the answer involves nested selects but i cant wrap my head around it.
ASKER CERTIFIED SOLUTION
Avatar of Brian Crowe
Brian Crowe
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of jmichael18
jmichael18

ASKER

Thanks!