Summary

This document is a tutorial on SQL. It covers various SQL commands and functions with examples. It's suitable for learners interested in database management and SQL.

Full Transcript

# SQL Zero to Hero ## SQL - ALIAS - AS: An alias is created with 'As' keyword. - `SELECT Column_name As alias_name FROM table_name;` - GROUP BY - Group by Column: - `SELECT Column_name(s) FROM table_name WHERE Condition GROUP BY column_name(s) ORDER BY column_name(s);`...

# SQL Zero to Hero ## SQL - ALIAS - AS: An alias is created with 'As' keyword. - `SELECT Column_name As alias_name FROM table_name;` - GROUP BY - Group by Column: - `SELECT Column_name(s) FROM table_name WHERE Condition GROUP BY column_name(s) ORDER BY column_name(s);` - Having: - `SELECT Column name (s) FROM table name WHERE condition GROUP BY Column_name (s) HAVING condition ORDER BY Column_name(s);` - ORDER BY - Order by (ASC) or ORDER BY DES: The order by keyword is used to sort the result-set in ascending or descending order. - `SELECT Column 1, Column 2, .... FROM table_name ORDER BY column 1, column 2, ..... ASC/DES;` - JOINS - Inner Join: This keyword selects that have matching values in both tables. - `SELECT Column_name(s) FROM table 1 INNER JOIN table 2 ON table.column_name = table2.column.name;` - Left Join: - `SELECT column_name (s) FROM table 1 LEFT JOIN table 2` - Right Join: - `SELECT column_name (s) FROM table 1 RIGHT JOIN table 2 ON table 1. Column_name = table 2. Column_name;` - Full Join: - `SELECT Column_name (s) FROM table 1 FULL OUTER JOIN table 2 ON table 1. Column_name = table 2. Column_name; WHERE Condition` - FUNCTIONS - AVG(): - `SELECT AVG(column_name) FROM table_name WHERE Condition;` - SUM(): - `SELECT SUM(column_name) FROM table_name WHERE condition;` - COUNT(): - `SELECT (Product ID) FROM Products;` - MIN(): - `SELECT MIN (Column_name) FROM table_name WHERE condition;` - MAX(): - `SELECT MAX(column_name) FROM table_name WHERE condition;` - WHERE - LIKE: - `SELECT column 1, Column 2... FROM table_name WHERE Column LIKE Pattern` - IN: - `SELECT Column_name(s) FROM table_name WHERE COlumn_name IN (Value 1, Value2,...);` - BETWEEN: - `SELECT Column_name FROM table_name WHERE Column_name BETWEEN Value 1 AND Value2;` - ANY: - `SELECT Column_name(s) FROM table_name WHERE Column_name Operator ANY (SELECT Column_name FROM table_name` - EXISTS: - `SELECT Column_name(s) FROM table_name WHERE Exists. SELECT Column_name FROM table_name WHERE (Condition);` - ALL: - `SELECT ALL Column_name(s) FROM table_name WHERE condition;` - AND: - `SELECT Column 1, Column 2,.... FROM table_name WHERE Condition 1 AND Condition 2 AND Condition 3.・・・・` - OR: - `SELECT Column 1, Column 2,.... FROM table_name WHERE condition 1 or Condition 2 or Condition 3...;` - NOT: - `SELECT Column 1, Column 2,.... FROM table_name WHERE NOT Condition;`

Use Quizgecko on...
Browser
Browser