Hi,
This is my first post so I hope I am not violating any Rules.
I have a Common Table Expression that returns 2 Columns, the 1st one uses ROW_NUMBER and has row numbers (rn) in such a way that they Can duplicate
I then use a 2nd Nested CTE with the Reference to the 1st one, but I want to retrieve only the 1st Row of the First CTE where RN = 1.
Is there a way to do it?
khtan
February 27, 2024, 8:46am
2
Show us your current query
1 Like
Ifor
February 27, 2024, 9:04am
3
;WITH cte_base AS (
SELECT ROW_NUMBER() ... AS row_num, FeeType
FROM ...
),
cte_nested AS (
SELECT TOP (1) *
FROM cte_base
WHERE row_num = 1
ORDER BY FeeType
)
1 Like
Hi, Thanks for taking the time, ScottPletcher's solution worked for me. Will make sure to post my query from next time.
Thanks for pointing me to the thread. Ill use that from my next post
Thanks Scott, this is exactly what I was looking for.