sql - Nested 'Where'? -
i have table
named actor
, column city
(cityid). want return number of actors in particular state
(stateid). catch have separate tables city
, county
, , state
(city has countyid, county has stateid). how in t-sql query?
i have solution involves nested select statements, like:
select count(1) actor a.cityid in (select cityid city countyid in...)
...but there more efficient way this? thanks
can use query output ---------------------------------------------------------- select count(actorid) actor inner join city c on a.cityid = c.cityid inner join country con on c.countryid = con.countryid inner join state s on con.stateid = s.stateid group s.stateid
Comments
Post a Comment