0% found this document useful (0 votes)
2 views1 page

SQL Syntax Guide

The SQL Syntax Guide provides essential SQL statements and commands for querying and managing data in databases. Key commands include SELECT for data retrieval, WHERE for filtering, and ORDER BY for sorting results. Additional functions like MIN, MAX, SUM, AVG, GROUP BY, HAVING, DISTINCT, SELECT TOP, and LIMIT are also outlined for effective data analysis.

Uploaded by

gowtham2022gi
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views1 page

SQL Syntax Guide

The SQL Syntax Guide provides essential SQL statements and commands for querying and managing data in databases. Key commands include SELECT for data retrieval, WHERE for filtering, and ORDER BY for sorting results. Additional functions like MIN, MAX, SUM, AVG, GROUP BY, HAVING, DISTINCT, SELECT TOP, and LIMIT are also outlined for effective data analysis.

Uploaded by

gowtham2022gi
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

SQL Syntax Guide

SQL Syntax Guide


SQL syntax is the foundation for querying and managing data in databases. You can use these
statements to extract insights and perform calculations.

Use this guide as a quick reference to review the essential SQL statements and commands that
are fundamental for interacting with and analyzing data effectively.

SQL statement Description Syntax


SELECT The SELECT statement is used to retrieve SELECT <column_name1>,
specific data from one or more columns in <column_name2> FROM
a table. <table_name>;
WHERE The WHERE statement is used to filter data SELECT <column_name1> FROM
that is subject to a specific condition. <table_name> WHERE
<column_name2> = <value2>;
ORDER BY The ORDER BY statement sorts the result SELECT <column_name1>,
set based on one or more columns, either <column_name2> FROM
ascending or descending. <table_name> ORDER BY
<column_name> ASC/DESC;
MIN and MAX The MIN and MAX statements are used to SELECT MIN(<column_name>)
get the smallest (min) or largest (max) FROM <table_name>;
value from a specific column.
SUM The SUM statement is used to get the total SELECT SUM(<column_name>)
sum of a numerical column. FROM <table_name>;
AVG The AVG statement is used to get the SELECT AVG(<column_name>)
average of a numerical column. FROM <table_name>;
GROUP BY The GROUP BY command is used to group SELECT <column_name1>,
rows that have the same values in SUM(<column_name2>) FROM
specified columns into summary rows. <table_name> GROUP BY
<column_name1>;
HAVING The HAVING command is used to filter SELECT <column_name1>,
records that work with GROUP BY. SUM(<column_name2>) FROM
<table_name> GROUP BY
<column_name1> HAVING
SUM(<column_name2>) > <value>;
DISTINCT The DISTINCT command is used to return SELECT DISTINCT <column_name>
only distinct (unique) values in a column, FROM <table_name>;
which eliminates duplicates.
SELECT TOP The SELECT TOP command is used to limit SELECT TOP <number>
the number of rows returned by the query <column_name1>,
to a specified number. <column_name2> FROM
<table_name>;
LIMIT The LIMIT command is used to specify the SELECT <column_name1>,
maximum number of records to return in <column_name2> FROM
the result set. <table_name> LIMIT <number>;

Page 1 of 1

You might also like