SELECT
= 3-Resources/Tools/Developer Tools/Data Stack/Procedural Languages/SQL Code to retrieve data from database
- Use Cases
- Syntax
- [[#
LIMIT
|LIMIT
]] - [[#
ORDER BY
|ORDER BY
]] - Inline Calculations
- Appendix: Links and References
- View data from set of columns in a table
- Combine data from multiple tables
- Filter results from above, perform custom calculations, etc.
SELECT [DISTINCT]
[COLUMN],
...
FROM
[SCHEMA].[TABLENAME]
WHERE
[CONDITIONAL STATEMENTS]
GROUP BY
[GROUPING FIELDS]
HAVING
[CONDITIONAL FILTER STATEMENTS AFTER GROUPING]
ORDER BY
[COLUMNS TO SORT];
Select All:
SELECT * FROM [SCHEMA].[TABLENAME];
- Sets maximum number of rows to return
- Is always the last line of the query
SELECT *
FROM [SCHEMA].[TABLENAME]
LIMIT 5
- Sort output rows
- Add
ASC
orDESC
- In MySQL,
NULL
values appear first w/ASC
- In MySQL,
SELECT *
FROM [SCHEMA].[TABLENAME]
ORDER BY [ORDERCOLUMN] DESC
LIMIT 5
- 2022-10-28
- SQL for Data Scientists
- 3-Resources/Tools/Developer Tools/Data Stack/Procedural Languages/SQL
- Databases
Jimmy Briggs [email protected] | 2022