Home > Software engineering >  Fill the null Value
Fill the null Value

Time:11-20

I want a select query that fills the null values in column 2 [Tags.1] with the distinct value from column 1 [ResourcesUD]

enter image description here

CodePudding user response:

try this:

 SELECT  ResourceID, isnull(Tags.1, select top 1 b.ResourceID from
 table b where b.ResourceID=a.ResourceID) FROM table a

CodePudding user response:

I didn't get the question correctly. If you want a select query that filters the null values in column 2, here is the query.

SELECT DISTINCT ResourceID, Tags.1 FROM table WHERE Tags.1 IS NULL

Not sure, what database you are using and the Tags.1 is a valid table name. Better if you can change it to Tags_1

  • Related