maximus1974
asked on
How to return the last row using ROW_COUNT
How can I have the following statement below return the last or highest row for rn?
SELECT wo_number, first_name, last_name
FROM (SELECT wo_number,
first_name,
last_name,
ROW_NUMBER() OVER(PARTITION BY wo_number ORDER BY first_name, last_name) rn,
COUNT(*) OVER (PARTITION BY wo_number) cnt
FROM ba_view_wo_labor
WHERE skill NOT LIKE '%INSPECTOR')
WHERE cnt > 1 AND rn = 1
ORDER BY wo_number
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
try this:
Open in new window
RegardsDavid
PS Not going to perform very well on larger datasets