試用版:
CREATE TABLE #Status
(
Id INT
, Name CHAR(2)
, status INT
, date DATETIME
);
INSERT INTO #Status
(Id, Name, status, date)
VALUES (1 -- Id - int
, 'xx' -- Name - char(2)
, 1 -- status - int
, '2016-06-27 14:05:17.447' -- date - datetime
),
(2 -- Id - int
, 'yy' -- Name - char(2)
, 2 -- status - int
, '2016-06-27 14:05:17.447' -- date - datetime
),
(3 -- Id - int
, 'zz' -- Name - char(2)
, 1 -- status - int
, '2016-06-27 14:05:17.447' -- date - datetime
),
(4 -- Id - int
, 'aa' -- Name - char(2)
, 2 -- status - int
, '2016-06-27 14:05:17.447' -- date - datetime
),
(5 -- Id - int
, 'bb' -- Name - char(2)
, 2 -- status - int
, '2016-06-27 14:05:17.447' -- date - datetime
),
(6 -- Id - int
, 'cc' -- Name - char(2)
, 1 -- status - int
, '2016-07-27 14:05:17.447' -- date - datetime
);
SELECT *
FROM #Status;
WITH cte
AS (SELECT *
FROM #Status
WHERE status <> 1
) ,
cteStatus1
AS (SELECT *
FROM #Status
WHERE status = 1
AND date <= GETDATE()
)
SELECT *
FROM cte
UNION
SELECT *
FROM cteStatus1;
あなたは実際にどのバージョンを使用していますか? –