Understanding SQL SELECT Statement

ViaByte.Net

SELECT * FROM employees LIMIT 10;

This query will retrieve the first 10 rows from the “employees” table.

Grouping Data with GROUP BY

The GROUP BY clause is used to group rows based on one or more columns. It is often used with aggregate functions like COUNT, SUM, AVG, etc. For example:

SELECT department, COUNT(*) FROM employees GROUP BY department;

This query will retrieve the “department” column and the count of employees in each department from the “employees” table. The result will show the number of employees grouped by department.

Bagikan:

Tinggalkan komentar