T-SQL reference › WHERE
WHERE in SQL Server: keep some rows
WHERE keeps rows that match. Text takes quotes. Numbers do not. Dates are safer as a range than as a string you hope converts.
Text and money
SELECT order_id, status, total_amount
FROM Orders
WHERE status = 'Shipped'
AND total_amount > 50
ORDER BY total_amount DESC;
Quotes on a number, none on text
status = Processing can look like a column. total_amount = '50' often still works via conversion and then one day it does not. Match the type.
Try it on Harbour & Co
Tom Gallagher (Warehouse Lead) needs this now: “Which orders are still Processing? I need order_id, order_date and total_amount.” Write the query, run it, send the results. Free.
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