How to Add If-Else Logic to SQL Queries(dev.to)
dev.to
How to Add If-Else Logic to SQL Queries
https://dev.to/helenanders26/sql-201-how-to-add-if-else-logic-to-sql-queries-41j
2 comments
CASE statements work with most if not all SQL dialects, some dialects such as MySQL support on top of that IF statements directly: https://dev.mysql.com/doc/refman/8.0/en/if.html
Also see Cross Apply and Outer Apply (MSSQL), often it is faster than using many CASE statements
https://www.mssqltips.com/sqlservertip/1958/sql-server-cross...
https://www.mssqltips.com/sqlservertip/1958/sql-server-cross...