我正在尝试从数据库中检索一些信息。特别是序列号。我需要利用SUBSTRING
函数来做到这一点,但我真的被卡住了。我需要得到所有序列号,他们的第13位数字是0和第14位是1。由于序列号可以随时改变,我想检查CustomerLotID
列的第13位0和14位数1将是最好的选择,但我有一些问题这样做。请注意,1,2,' 2/28/2017'在select语句仅用于测试之后。
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
答案 0 :(得分:2)
试试这个:
WHERE SUBSTRING(customerlotid ,13,2) = '01'