Home » SQL

SQL Clauses



Define SQL clauses: Here, we are going to learn about where clauses, group by clauses, having clauses, order by clauses.
Submitted by Preeti Jain, on March 30, 2018

SQL Clauses

SQL clauses are the special/reserve words, which have a specific meaning in a SQL language.

Note: We should prefer to write clauses in capital letters but it is not mandatory.

1) WHERE Clause

Where clause is used to fetch a conditional record. We should implement where clause whenever condition required.

Syntax:

SELECT col1,col2 FROM tablename WHERE col1 = value;

2) GROUP BY Clause

GROUP BY clauses is used to fetch a grouping record. We should implement GROUP BY clauses whenever grouping required.

GROUP BY clauses is used to arrange similar records into groups.

Syntax:

SELECT col1,col2 FROM tablename GROUP BY columnname;

3) HAVING Clause

HAVING clauses is used to fetch a conditional record after grouping. We should implement HAVING clauses whenever condition required after grouping.

HAVING clauses works on those rows which returned by GROUP BY clauses.

Syntax:

SELECT col1,col2.....coln 
FROM tablename 
WHERE colname = value 
GROUP BY colname 
HAVING colname = value;

ORDER BY Clause

ORDER BY clauses is used to fetch sorted record. We should implement ORDER BY clauses whenever sorting required.

ORDER BY clauses is used to sort records either in ascending(ASC) or descending order(DESC) based on one or more column.

Syntax:

SELECT col1,col2.....coln 
FROM tablename 
WHERE colname = value 
GROUP BY colname 
HAVING colname = value 
ORDER BY columname (asc/desc);





Was this page helpful? Please share with your friends...

Are you a blogger? Join our Blogging forum.




Comments and Discussions





Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing » Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates


© https://www.includehelp.com (2015-2018), Some rights reserved.




close Like other websites, this site uses cookies to deliver relevant ads based on your interest, by using our website, you acknowledge that you have read our privacy policy.