SQL Server:限制填充零值直至使用特定文本
我有一个cte,我在第100行之前通过使用以下脚本在第100行之前将零值填充,
SELECT [YearMonth],grp,
CASE WHEN grp>grp
THEN (FIRST_VALUE([Value 1]) over (partition by grp order by [YearMonth]))
问题是我希望“最新”之后的行是无效的,但我不希望删除这些行。我需要显示其他列中的值。我会感谢任何帮助。
编辑
straw
年度 | 值1 |
---|---|
2021-01 | 0.9575 |
2021-02 | NULL |
2021-03 | NEULL |
2021-04 | null |
2021-05 | NULL |
2021-06 | 0.9875 |
预期台式
年度 | 值 |
---|---|
strong | strong |
< / | / |
2021-03 | 0.9575 |
2021-04 | 0.9575 |
2021-05 | 0.9575 |
2021-06 | 0.9875 |
I have a CTE on which i am filling null values with the previous value before row 100 available by using the following script
SELECT [YearMonth],grp,
CASE WHEN grp>grp
THEN (FIRST_VALUE([Value 1]) over (partition by grp order by [YearMonth]))
The problem is that i want the rows after the "Latest" to be null but i dont want these rows to be deleted cause there are values in other columns which i need to show. I would appreciate of any help.
EDIT
Current Table
YearMonth | Value 1 |
---|---|
2021-01 | 0.9575 |
2021-02 | NULL |
2021-03 | NULL |
2021-04 | NULL |
2021-05 | NULL |
2021-06 | 0.9875 |
Expected table
YearMonth | Value 2 |
---|---|
2021-01 | 0.9575 |
2021-02 | 0.9575 |
2021-03 | 0.9575 |
2021-04 | 0.9575 |
2021-05 | 0.9575 |
2021-06 | 0.9875 |
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论