0 votes
in Sql by
What are some common clauses used with SELECT query in SQL?

1 Answer

0 votes
by
Some common SQL clauses used in conjuction with a SELECT query are as follows:

WHERE clause in SQL is used to filter records that are necessary, based on specific conditions.

ORDER BY clause in SQL is used to sort the records based on some field(s) in ascending (ASC) or descending order (DESC).

SELECT *

FROM myDB.students

WHERE graduation_year = 2019

ORDER BY studentID DESC;

GROUP BY clause in SQL is used to group records with identical data and can be used in conjuction with some aggregation functions to produce summarized results from the database.

HAVING clause in SQL is used to filter records in combination with the GROUP BY clause. It is different from WHERE, since WHERE clause cannot filter aggregated records.

SELECT COUNT(studentId), country

FROM myDB.students

WHERE country != "INDIA"

GROUP BY country

HAVING COUNT(studentID) > 5;

Related questions

0 votes
asked May 22, 2022 in Sql by AdilsonLima
0 votes
asked Jan 23 in Oracle by SakshiSharma
...