CREATE TABLE GGGG(ID VARCHAR(50))
INSERT INTO GGGG VALUES('A'),('B'),('C'),('D'),(NULL),(NULL),(NULL),(NULL)
SELECT * FROM GGGG
;WITH X AS(SELECT ID,ROW_NUMBER() OVER(PARTITION BY ID ORDER BY ID) AS ROW_NO FROM GGGG)
---SELECT * FROM X
DELETE FROM X WHERE ID IS NULL AND ROW_NO IN(1,2)
INSERT INTO GGGG VALUES('A'),('B'),('C'),('D'),(NULL),(NULL),(NULL),(NULL)
SELECT * FROM GGGG
;WITH X AS(SELECT ID,ROW_NUMBER() OVER(PARTITION BY ID ORDER BY ID) AS ROW_NO FROM GGGG)
---SELECT * FROM X
DELETE FROM X WHERE ID IS NULL AND ROW_NO IN(1,2)
No comments:
Post a Comment