0

So, I got myself in a situation where I have 36 columns and need to essentially do a "MIN" on ALL those columns. Not a MIN by grouping, rather, what I need is what the 2022-and-after LEAST function does.

Does anyone have any suggestion of how I could accomplish this? I did some research and reading, but didn't find anything that wasn't IIF, which, with 36 columns, well, it seems a bit uglier-than-ugly.

Dale K
  • 25,246
  • 15
  • 42
  • 71
Isaac
  • 17
  • 4
  • Its not clear what you are asking. Please provide sample data and desired results (even if less columns) to illustrate. – Dale K Oct 19 '22 at 22:11
  • 2
    https://www.mssqltips.com/sqlservertip/4067/find-max-value-from-multiple-columns-in-a-sql-server-table/ – Stuck at 1337 Oct 19 '22 at 22:12
  • See https://stackoverflow.com/questions/71022/sql-max-of-multiple-columns – Luke Kubat Oct 19 '22 at 22:19
  • @rhythmWasaLurker Thank you, that link was spot on. I used option 1 on https://www.mssqltips.com/sqlservertip/4067/find-max-value-from-multiple-columns-in-a-sql-server-table/ and it worked just like LEAST which is precisely what I needed. Thanks, you should put that as an answer maybe? Everyone please don't crucify me if that's wrong, I'm new-ish to stack overflow, thanks again. – Isaac Oct 19 '22 at 22:27

0 Answers0