T-SQL reference › IIF
IIF in SQL Server: a short CASE
IIF(condition, a, b) is CASE WHEN condition THEN a ELSE b END. Fine for yes/no. For Small / Medium / Large, write CASE so the edges stay visible.
Two-way
SELECT order_id, total_amount,
IIF(total_amount >= 150, 'Large', 'Not large') AS size
FROM Orders;
Three bands belong on CASE WHEN.
Try it on Harbour & Co
James Rowe (Sales Manager) needs this now: “For a slide: label last month’s orders Small, Medium or Large.” Write the query, run it, send the results. On the paid plan.
Take the ticket →Learn it on a real ticket
Monday is free on WorkSQL. A colleague’s ticket lands, you write the T-SQL, we mark it. No videos. Five minutes.
Clock in free See Monday’s tickets