1.

What are some common clauses used with SELECT query in SQL?

Answer»

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.studentsWHERE graduation_year = 2019ORDER BY studentID DESC;
  • GROUP BY clause in SQL is used to group records with identical data and can be used in conjunction 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 the WHERE clause cannot filter aggregated records.
SELECT COUNT(studentId), countryFROM myDB.studentsWHERE country != "INDIA"GROUP BY countryHAVING COUNT(studentID) > 5;


Discussion

No Comment Found