Skip to main content
added 3 characters in body
Source Link
Xin
  • 37.1k
  • 18
  • 89
  • 99

Why not try IIF function (requires SQL Server 2012 and later)

IIF(a>b, a, b)

That's it.

(Extra hint: be careful about either a/ or b is null, as in this case the result of a>b will be false. So b will be the return result if either is null) (Also by system design, column null is not a good practice)

Why not try IIF function (requires SQL Server 2012 and later)

IIF(a>b, a, b)

That's it.

(Extra hint: be careful about either a/b is null, as in this case the result of a>b will be false. So b will be the return result if either is null)

Why not try IIF function (requires SQL Server 2012 and later)

IIF(a>b, a, b)

That's it.

(Extra hint: be careful about either a or b is null, as in this case the result of a>b will be false. So b will be the return result if either is null) (Also by system design, column null is not a good practice)

added 8 characters in body
Source Link
Xin
  • 37.1k
  • 18
  • 89
  • 99

Why not try IIF function (requires SQL Server 2012 and later)

IIF(a>b, a, b)

That's it.

(HintExtra hint: be careful about either would be a/b is null, sinceas in this case the result of a>b will be false whenever either is null. So b will be the return result in this caseif either is null)

Why not try IIF function (requires SQL Server 2012 and later)

IIF(a>b, a, b)

That's it.

(Hint: be careful about either would be null, since the result of a>b will be false whenever either is null. So b will be the result in this case)

Why not try IIF function (requires SQL Server 2012 and later)

IIF(a>b, a, b)

That's it.

(Extra hint: be careful about either a/b is null, as in this case the result of a>b will be false. So b will be the return result if either is null)

add null
Source Link
Xin
  • 37.1k
  • 18
  • 89
  • 99

Why not try IIF function (requires SQL Server 2012 and later)

IIF(a>b, a, b)

That's it.

(Hint: be careful about either would be null, since the result of a>b will be false whenever either is null. So b will be the result in this case)

Why not try IIF function (requires SQL Server 2012 and later)

IIF(a>b, a, b)

That's it.

Why not try IIF function (requires SQL Server 2012 and later)

IIF(a>b, a, b)

That's it.

(Hint: be careful about either would be null, since the result of a>b will be false whenever either is null. So b will be the result in this case)

added 14 characters in body
Source Link
Xin
  • 37.1k
  • 18
  • 89
  • 99
Loading
Source Link
Xin
  • 37.1k
  • 18
  • 89
  • 99
Loading