question

Pragati avatar image
Pragati asked

Row number function in the join clause

Row number function in the join condition. So I have a requirement where i need to return two values (from the same column) from a joining table. I have an id mapped to two different users which are mapped to two different territories resp. In my select query i want to have the territory with row_number 1 as my primary territory column and the other territory as usual. But if i use a cte or where clause on the entire result set then I get only one row. However, I want to return both rows as they would have different territories but same primary territory for an id. Any suggestions?
joinsrownumber
1 comment
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

can you post some example table structures and data
3 Likes 3 ·

0 Answers

·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.