I am trying to retrieve some information from our database. Specifically serial numbers. I need to utilize the SUBSTRING function to do this however, I am really stuck. I need to get all serial numbers who's 13th digit is a 0 and 14th digit is a 1. Since the serial numbers can change at anytime I thought checking the CustomerLotID columns for a 13th digit 0 and 14th digit 1 would be the best option however I am having some issues doing this. Please note that the 1, 2, '2/28/2017' after the select statements are for testing only.
SELECT
1, 2, '2/28/2017', '06:00', TX.OperationID, FriendlyName,
COUNT(DISTINCT(CustomerLotID)) AS SerialNumber
FROM
fsWIPTxHist Tx
INNER JOIN
FactoryServerMES.dbo.fsOperation O ON TX.OperationID = O.OperationID
WHERE
customerlotid = SUBSTRING('0',13,1) --<> '5D25984G14120%'
AND (TX.DateCreated BETWEEN '2/28/2017 10:00:00' AND '2/28/2017 10:59:59')
AND (Status = 'Avail')
AND TX.OperationID IN (3100)
GROUP BY
TX.OperationID, FriendlyName
WHERE SubString(customerlotid, 13, 2) = '01'doesn't work for you? Did you consider reading the documentation for SubString?