3 ms·
How to Add If-Else Logic to SQL Queries
- linkerzx 7y agoCASE 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 https://dev.mysql.com/doc/refman/8.0/en/if.html
- reportgunner 7y agoAlso 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-apply-and-outer-apply/ https://www.mssqltips.com/sqlservertip/1958/sql-server-cross...