Sobes.tech
Junior — Middle

Can you list the main operators used for data retrieval in SQL?

sobes.tech AI

Answer from AI

Main operators for data selection in SQL:

  • SELECT — selects columns from a table.
  • FROM — specifies the table from which data is selected.
  • WHERE — filters rows based on a condition.
  • ORDER BY — sorts the result by one or more columns.
  • GROUP BY — groups rows by the value of one or more columns.
  • HAVING — filters groups created by GROUP BY.
  • LIMIT (or TOP) — limits the number of rows returned.

Example:

SELECT name, COUNT(*) as count
FROM users
WHERE active = 1
GROUP BY name
HAVING count > 5
ORDER BY count DESC
LIMIT 10;