Bernard Polman
Bernard Polman

Reputation: 855

SQL - multiply selected value by -1 if value is not null

I'm selecting a value from a table and multiply it by -1 because I need the value to be negative:

sv.SemVers_AnzahlProd*(-1)

But the value could be NULL, so I want to check somehow if the value is NULL. If it is, don't multiply it by -1.

How can I achieve this? I check if ISNULL() is suitable for this problem, but it's not because I need to multiply the value by -1 is the value is NOT NULL.

Upvotes: 0

Views: 100

Answers (1)

Peter Smith
Peter Smith

Reputation: 5550

There is no need to do anything:

SELECT -1 * NULL

returns a value of NULL

Upvotes: 5

Related Questions