Closed. This question needs details or clarity . It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post .
Closed 8 days ago.
Improve this question
I have data like this
id | name |
---|---|
1 | AA |
2 | BB |
3 | CC |
4 | DD |
5 | EE |
Given that, I have to use a select statement like this.
select *
from (
select
row_number() over (partition by id order by id asc) as row
, id
, name
) tmp
where tmp.id in (2,3,4) -- Just an example of condition in outer query
I could not temper with outer query [tmp] selection. when I want display data to be as
row | id | name |
---|---|---|
1 | 2 | BB |
2 | 3 | CC |
3 | 4 | DD |
Is there any way to achieve row_number()
as intended without creating temp table and use store procedure to delete and insert every time it queries data with some condition.
1条答案
按热度按时间2ekbmq321#
The best case I could find for now is using a new temporary table for the results wanted it to be and a stored procedure to truncate and insert it as conditions specified