I'm using an Access database and I'd like to have a query use different WHERE statements based on the area. I'm fairly new to SQL, so I don't know if a case statement can do this or if I'm using it correctly. I could make two queries and join them in the third, but that seems like poor solution. If it's possible to make a single SQL query to handle this I'd appreciate it.
Code:
SELECT
tblTemp.State,
tblTemp.Person,
tblTemp.Occupation
FROM
CASE tblTemp.Area
WHEN 'NY' THEN
WHERE
tblTemp.Occupation<>''
ELSE
WHERE
tblTemp.Occupation<>'' AND
tblTemp.Occupation<>'Sales'
END
GROUP BY tblTemp.State, tblTemp.Occupation;