Files
sql-scripts/paul_snippets/ProductionChecks/QuarantineItems_Times.sql
2025-02-27 11:46:26 +01:00

22 lines
501 B
Transact-SQL

USE SwissIndex_Products_Work
GO
DECLARE @t TABLE (ItemType VARCHAR(100), IndexCode INT, Dt DATETIME, INDEX IxDt (Dt))
INSERT INTO @t (ItemType, IndexCode, Dt)
SELECT ItemType, IndexCode, Dt
FROM (
SELECT ItemType, 128 AS IndexCode, MIN(Db_InsDT) AS Dt
FROM dbo.QuarantineItems
WHERE NOT ItemType = 'ARTICLE'
GROUP BY ItemType
UNION ALL
SELECT ItemType, IndexCode, MIN(Db_InsDT) AS Dt
FROM dbo.QuarantineItems
WHERE ItemType = 'ARTICLE'
GROUP BY ItemType, IndexCode
) g
SELECT * FROM @t
ORDER BY Dt