Friday, December 22, 2023

List 50% Rows of a table

 Query Show 50% Rows of a table

WITH employee_ranking AS (
  SELECT
    employee_id,
    last_name,
    first_name,
    salary,
    NTILE(2) OVER (ORDER BY salary ) as ntile
  FROM employee
)
SELECT
  employee_id,
  last_name,
  first_name,
  salary
FROM employee_ranking
WHERE ntile = 1
ORDER BY salary

No comments :

Post a Comment