Anthony Foschini Anthony Foschini - 4 months ago 7
SQL Question

Multiple Wildcards/Filters for SQL

I am attempting to only retrieve Business Unit specific information from a large datamart, and would like to structure my query to eliminate unrelated DepartmentIDs.

In plainspeak, the end goal is to filter on ALL DepartmentIDs starting with "AN" and ending in 0, P, A, N, R, V, C, L, W, E, or Y.

Currently the query starts with:

FROM bbms_tpirc.dbo.LaborDetailByName LaborDetailByName
WHERE (LaborDetailByName.post_year='2016') AND
(LaborDetailByName.center_id='APEEN') AND
( Like 'AN%')

but I am struggling with the next section.

Using another
AND ( Like '%0', '%P')
etc doesn't return anything in the dataset. Might I be overfiltering, or simply forgetting an argument?


You can replace your filter clause

( Like 'AN%')