Delete without row_num

0

Please login or register to vote for this query.

(click on this box to dismiss)

Anime and Manga

Q&A for anime and manga fans

CREATE TABLE #YourTable
    ([salary] int)
;
    
INSERT INTO #YourTable
    ( [salary])
VALUES
    ( 20000.00),
    ( 20000.00),
    ( 20000.00),
    ( 50000.00),
    ( 50000.0)
;

   DELETE T1
    FROM #YourTable T1 WITH(TABLOCKX)
    WHERE CAST(T1.%%physloc%% AS BIGINT)
    NOT IN (SELECT MAX(CAST(%%physloc%% AS BIGINT))
    FROM #YourTable
    GROUP BY Salary
     )
            
  SELECT *
  FROM #YourTable

Enter Parameters

Options:
Switch to meta site
loading Hold tight while we fetch your results