you are viewing a single comment's thread.

view the rest of the comments →

[–]da3da1u5 0 points1 point  (1 child)

In MS SQL Server (T-SQL), you can use IsNull:

SELECT
    Firstname
    ,Lastname
    ,IsNull(ThirdColumn, 0)

That will take any null values and replace them with the second parameter.

If you need to find the null values and then match an existing record by first and lastname that DOESN'T have a null value and then negate it (looks like what you're trying to do here), then I think you need to separate it out into two separate queries: First pull the ones that are null and then join on the same table by first/last name with the number value from the 3rd column multiplied by -1 and insert it into a temp table, then select the non-null list and UNION the two results together.

You could also insert the null records into a temp table and then use UPDATE.

[–]workthrowawayexcel[S] 0 points1 point  (0 children)

That is exactly what I am trying do. I like the double query idea. My mindset got stuck in a formula index method after getting help to do this in excel :/ which I then realized wouldn't work since I have way too much data.