Hello everyone,
I am just getting into SQL and I am having a rough time figuring this one out. I am trying to pull a distinct count of a column based on the first two charecters. here is what I have so far;
SQL
SELECT count (distinct loc.externalname) "2B"
from ant.wmsstockitem si
join ant.wmsloadunit lu on lu.id = si.loadunit_id
join ant.wmslocation loc on loc.id = lu.location_id
where (si.ss_state) = 'WIP_DCC' and loc.externalname LIKE '2B%' AND (si.ss_reasontext) !='Missing best before date'
This returns one row and one column with a count of every unique location that starts with 2B. I am looking for a column that counts every unique location that starts with 1A, then a seperate column for 1B, 2A, 2B, 3A, 3B and so on. Thank you in advance for any help.