我想要一個選擇查詢,用第 1 列 [ResourcesUD] 中的不同值填充第 2 列 [Tags.1] 中的空值
The given table:
ReourceID [Tags.1]
1x ws
2x NULL
1x ws
3x qs
2x sg
4x ee
3x NULL
4x NULL
2x sg
預期結果:
ReourceID [Tags.1]
1x ws
2x sg
1x ws
3x qs
2x sg
4x ee
3x qs
4x ee
2x sg
uj5u.com熱心網友回復:
嘗試這個:
SELECT ResourceID, isnull(Tags.1, select top 1 b.ResourceID from
table b where b.ResourceID=a.ResourceID) FROM table a
uj5u.com熱心網友回復:
我沒有正確地回答問題。如果您想要一個過濾第 2 列中的空值的選擇查詢,這里是查詢。
SELECT DISTINCT ResourceID, Tags.1 FROM table WHERE Tags.1 IS NULL
不確定,您使用的是什么資料庫, Tags.1 是有效的表名。如果你能把它改成 Tags_1 就更好了
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/536645.html
標籤:数据库选择
