SQL Basics - The Select Statement
Data Analytics

SQL Basics - The Select Statement

SQL is an an abbreviation for Structured Query Language. SQL is made up of very few words to provide simple and efficient way to read and write data from database. The sequence of SELECT clauses is mentioned below. These are all some of the SQL reserved words to retrieve the data.

  1. SELECT 
  2. FROM
  3. WHERE
  4. GROUP BY
  5. HAVING
  6. ORDER BY

Note - SQL is not case sensitive

Example Table - Students

student-idstudent _namegenderAttendance AgelocationClasssectionContact _noCGPA
1AB21AmanMale56.2315Bangalore9A76543211207.9
2AB22BhavanaFemale89.6517Mangalore10B98765432109.3
1AB23ArjunMale56.2315Bangalore9A76543254549.9
2AB24BhuvanMale69.6516Mysore10B98765439898.3
1AB25AmalaFemale76.2315Bangalore9A76576541206.9
2AB26BhavyaFemale59.6513Mandya8B98765675439.3

 

Explanation

CLAUSESYNTAXExampleExplanation
SELECT SELECT (Col_ name)SELECT (student_ name )When specific columns are to be retrieved from a dataset.
FROMFROM ( Table_ name)FROM ( Students )From which table the fields(columns) are to be retrieved.
WHEREWHERE ( condition for specific rows)WHERE ( attendance > 80 )The rows that satisfy the given condition. 
GROUP BYGROUP BY (Col_ name)GROUP BY ( gender )Grouping the rows based on a column name.
HAVINGHAVING ( condition for specific groups)HAVING ( cgpa  > 7 )The groups that satisfy the given condition.
ORDER BYORDER BY ( Col_ name)ORDER BY ( student _ id)Sorting the output in ascending order.

Output

Bhavana

As she is the only student having  cgpa  > 7  and attendance > 80

This is the simplest explanation for the sequence of the execution of the select statement in SQL.

 

 

 

  • Sangeetha Rani S
  • Dec, 27 2022

Add New Comments

Please login in order to make a comment.

Recent Comments

Be the first to start engaging with the bis blog.