🌐
W3Schools
w3schools.com › sql › sql_syntax.asp
SQL Syntax
SQL HOME SQL Intro SQL Syntax SQL Select SQL Select Distinct SQL Where SQL Order By SQL And SQL Or SQL Not SQL Insert Into SQL Null Values SQL Update SQL Delete SQL Select Top SQL Aggregate Functions SQL Min() SQL Max() SQL Count() SQL Sum() SQL Avg() SQL Like SQL Wildcards SQL In SQL Between SQL Aliases SQL Joins SQL Inner Join SQL Left Join SQL Right Join SQL Full Join SQL Self Join SQL Union SQL Union All SQL Group By SQL Having SQL Exists SQL Any SQL All SQL Select Into SQL Insert Into Select SQL Case SQL Null Functions SQL Stored Procedures SQL Comments SQL Operators
Discussions

A quick cheatsheet reference for SQL queries
Very nice to have for anyone getting started with SQL. I’ve been writing SQL for about 7 years now and the only thing that I don’t use in your list on a daily basis is the “having” clause. I see this a lot with younger folks coming into the workforce. We conduct a very simple SQL test and most of them use the having clause for everything. Personally, I’m not a huge fan of it because I like to filter the data on the front end. However, I know that there are use cases for the having clause, I just don’t use it often. Again, great job on the write up! More on reddit.com
🌐 r/learnprogramming
62
747
October 2, 2018
Good resources to learn complex SQL queries ?

Brent Ozar has a great blog/newsletter.

A lot of thier examples use the stack overflow database that you can download and tinker with or query directly here: https://data.stackexchange.com/stackoverflow/query/new

More on reddit.com
🌐 r/SQL
12
28
June 23, 2017
5 best practices for writing good SQL queries

I like seeing content like this and support general practices for writing queries, but one note:

  1. Define all the necessary fields for SELECT instead of using SELECT *

This isn't always true. For example lets say you start with a query such as:

select
a
, b
, c
, d
from table

Objectively even if the table only has 4 columns, it is probably better to spell them out as opposed to using *, however:

select *
from (
select
*
, stuff
from (
select
a
, b
, c
, d
from table x
) y
) z

Here you can see that when using recursive sub-queries, etc., that you may want to use a * because otherwise you are going to be spelling out the same basic list multiple times in a row, and this makes it much more of a pain in the ass to go in and make changes. Instead of making them in one place, you're making them in 10 places. Also, you might want to consider creating a view that is a select * from table so that new columns automatically show up and filter into front end applications like Tableau. So now if you update a stored procedure and add a column, you don't have to go adding it in multiple places.

More on reddit.com
🌐 r/SQL
29
50
September 24, 2018
Are there any best practices for writing SQL queries?
Benchmark everything , theory is one thing but experiment like a scientist (with a grounded hypothesis to start) More on reddit.com
🌐 r/SQLServer
21
8
February 27, 2019
🌐
GeeksforGeeks
geeksforgeeks.org › sql › sql-concepts-and-queries
SQL Concepts and Queries - GeeksforGeeks
The CREATE DATABASE statement is used to create a new database in the SQL server. ... The USE statement selects a specific database so that all subsequent queries are executed within that database.
Published   1 month ago
🌐
LearnSQL.com
learnsql.com › blog › basic-sql-query-examples
20 Basic SQL Query Examples for Beginners | LearnSQL.com
Like any language – programming or natural – it is used to communicate, to talk. SQL is designed to talk to a database. We do that using sentences that we call queries, which are SQL commands for retrieving data from the database.
🌐
ByteScout
bytescout.com › blog › 20-important-sql-queries.html
TOP-70 Most Important SQL Queries in 2023 – ByteScout
Wouldn’t it be great if there were a set of conditions you could depend on every time? The complex SQL queries using ANY and ALL can make this ideal a reality! Let’s look at how the ALL keyword is used to include records only when a set of conditions is true for ALL records.
🌐
Microsoft Learn
learn.microsoft.com › en-us › sql › t-sql › queries › queries
Queries - SQL Server | Microsoft Learn
Use these statements to add, modify, query, or remove data from a SQL Server database.
🌐
Metabase
metabase.com › learn › sql › working-with-sql › sql-best-practices
Best practices for writing SQL queries | Metabase Learn
For columns that typically go together in queries (such as last_name, first_name), consider creating a composite index. The syntax is similar to creating a single index. For example: CREATE INDEX full_name_index ON customers (last_name, first_name) Some databases, like PostgreSQL, offer insight into the query plan based on your SQL code.
🌐
AWS
aws.amazon.com › what is cloud computing? › cloud computing concepts hub › developer tools › what is sql (structured query language)?
What is SQL? - Structured Query Language (SQL) Explained - AWS
1 week ago - SQL statements, or SQL queries, are valid instructions that relational database management systems understand. Software developers build SQL statements by using different SQL language elements.
Find elsewhere
🌐
DataCamp
datacamp.com › tutorial › sql-query-examples-and-tutorial
SQL Query Examples and Tutorial | DataCamp
July 28, 2022 - With nested queries, you can perform very complicated operations but in multiple steps keeping the readability and understandability of code intact. Q15: Determine the average profitability of the movies in the table ‘films’. Hint: You calculated profitability earlier, with Q3. Now you have to take the result from this query and apply the AVG function to it. ... We removed the negative value from ‘Fight Club’ in the calculation within the inner SQL query by adding gross > budget.
🌐
Secoda
secoda.co › learn › mastering-sql-query-structure-components-syntax-and-best-practices
Mastering SQL Query Structure: Components, Syntax, and Best Practices | Secoda
August 12, 2024 - Learn the essential components of SQL queries, including SELECT, INSERT, and WHERE clauses, and how to structure effective queries for data retrieval and manipulation.
🌐
GeeksforGeeks
geeksforgeeks.org › sql › sql-select-query
SQL SELECT Query (With Examples) - GeeksforGeeks
The SQL SELECT statement is used to retrieve data from one or more tables and display it in a structured format of rows and columns.
Published   2 weeks ago
🌐
DocuSign
blink.ucsd.edu › technology › help-desk › queries › SQL › index.html
How to Create a SQL Statement
Use this guide to review how to create a select SQL statement to use in the SQL Executer.
🌐
W3Schools
w3schools.com › sql › sql_examples.asp
SQL Examples
SQL HOME SQL Intro SQL Syntax SQL Select SQL Select Distinct SQL Where SQL Order By SQL And SQL Or SQL Not SQL Insert Into SQL Null Values SQL Update SQL Delete SQL Select Top SQL Aggregate Functions SQL Min() SQL Max() SQL Count() SQL Sum() SQL Avg() SQL Like SQL Wildcards SQL In SQL Between SQL Aliases SQL Joins SQL Inner Join SQL Left Join SQL Right Join SQL Full Join SQL Self Join SQL Union SQL Union All SQL Group By SQL Having SQL Exists SQL Any SQL All SQL Select Into SQL Insert Into Select SQL Case SQL Null Functions SQL Stored Procedures SQL Comments SQL Operators
🌐
Codecademy
codecademy.com › article › sql-commands
SQL Commands List: Basic Database Queries | Codecademy
Explore the SQL execution order step-by-step and understand how queries run behind the scenes.
🌐
HubSpot
blog.hubspot.com › home › marketing › an introductory sql tutorial: how to write simple queries
An Introductory SQL Tutorial: How to Write Simple Queries
June 10, 2025 - Calculations and organization also can be done within a query. That‘s where the ORDER BY and GROUP BY functions come in. First, we’ll look at our SQL queries with the ORDER BY and then GROUP BY functions.
🌐
GUVI
guvi.in › blog › database › 15+ most common sql queries with examples that every developers should know
15 Most Common SQL Queries with Examples
February 26, 2026 - SQL queries are commands used to manage and manipulate data in relational databases. They allow users to retrieve, insert, update, and delete records efficiently using statements like SELECT, INSERT, UPDATE, and DELETE.
🌐
W3Schools
w3schools.com › sql › sql_intro.asp
SQL Introduction
SQL can execute queries against a database · SQL can retrieve data from a database · SQL can insert records in a database · SQL can update records in a database · SQL can delete records from a database · SQL can create new databases · SQL can create new tables in a database ·
🌐
W3Schools
w3schools.com › sql › sql_select.asp
SQL SELECT Statement
SQL HOME SQL Intro SQL Syntax SQL Select SQL Select Distinct SQL Where SQL Order By SQL And SQL Or SQL Not SQL Insert Into SQL Null Values SQL Update SQL Delete SQL Select Top SQL Aggregate Functions SQL Min() SQL Max() SQL Count() SQL Sum() SQL Avg() SQL Like SQL Wildcards SQL In SQL Between SQL Aliases SQL Joins SQL Inner Join SQL Left Join SQL Right Join SQL Full Join SQL Self Join SQL Union SQL Union All SQL Group By SQL Having SQL Exists SQL Any SQL All SQL Select Into SQL Insert Into Select SQL Case SQL Null Functions SQL Stored Procedures SQL Comments SQL Operators
🌐
Microsoft Support
support.microsoft.com › en-us › office › access-sql-basic-concepts-vocabulary-and-syntax-444d0303-cde1-424e-9a74-e8dc3e460671
Access SQL: basic concepts, vocabulary, and syntax - Microsoft Support
When you want to retrieve data from a database, you ask for the data by using Structured Query Language, or SQL. SQL is a computer language that closely resembles English, but that database programs understand.