DISTINCT & LIMIT

DISTINCT removes duplicate values from your results, and LIMIT caps how many rows come back. Neither changes what data exists — just how much of it you see.

DISTINCT

Without it, selecting a column returns one row per matching row in the table — duplicates included. DISTINCT collapses repeats down to unique values:

every department name, once each
Result

You can use it with more than one column too — then a row only counts as a duplicate if every listed column matches:

distinct department + salary combos
Result

LIMIT

LIMIT is mostly a practical tool: previewing a huge table, paginating results, or just answering "give me the first few." Combine it with ORDER BY for anything meaningful — otherwise which rows you get back is arbitrary:

two highest earners
Result
Note: some databases (like SQL Server) use TOP instead of LIMIT, with slightly different syntax — the idea is the same everywhere, but check your database's docs if a query doesn't run as expected.