welcome to Stack Overflow. So, looks like you're asking two questions there.
- Regarding getting the count from four separate tables, I suggest running the same SQL query you've written on these four tables, saving each query output to a single view, and then running a group-by query to calculate the total count. Something like
SELECT count(*), p2 from <your_view> group by p2
- Selecting queries from multiple postcodes can be achieved using OR statements with your where clause. So, taking your original query,
SELECT p2, COUNT(*) FROM dsf_2022_raw_new
WHERE p2 LIKE 'BA'
OR WHERE p2 LIKE 'DL'...
Hope this helps. Happy coding
group byandunionUNION ALLthe tables. Or, if you really need separate tables, create a view that does UNION ALL.