sql:select
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
sql:select [2022/07/08 08:42] – 185.192.71.135 | sql:select [2022/07/08 09:12] (current) – 185.92.25.28 | ||
---|---|---|---|
Line 18: | Line 18: | ||
---- | ---- | ||
- | ===== Fetch selected | + | ===== Fetch specific |
<code sql> | <code sql> | ||
Line 36: | Line 36: | ||
---- | ---- | ||
+ | ===== Fetch from two tables ===== | ||
- | [[SQL:SELECT:Fetch all data from a table|Fetch all data from a table]] | + | <code sql> |
+ | SELECT | ||
+ | INNER JOIN Teachers | ||
+ | ON Students.teacher = Teacher.no | ||
+ | </ | ||
- | [[SQL: | + | ---- |
- | [[SQL:SELECT:Fetch selected columns | + | ===== Fetch maximum age from a table ===== |
+ | |||
+ | <code sql> | ||
+ | SELECT | ||
+ | FROM Students; | ||
+ | </ | ||
+ | |||
+ | ---- | ||
+ | |||
+ | ===== Fetch minimum age from a table ===== | ||
+ | |||
+ | <code sql> | ||
+ | SELECT MIN(age) | ||
+ | FROM Students; | ||
+ | </ | ||
+ | |||
+ | ---- | ||
+ | |||
+ | ===== Fetch sum of ages from a table ===== | ||
+ | |||
+ | <code sql> | ||
+ | SELECT SUM(age) | ||
+ | FROM Students; | ||
+ | </ | ||
+ | |||
+ | ---- | ||
+ | |||
+ | ===== Fetch average age from a table ===== | ||
+ | |||
+ | <code sql> | ||
+ | SELECT AVG(age) | ||
+ | FROM Students; | ||
+ | </ | ||
+ | |||
+ | ---- | ||
+ | |||
+ | ===== Fetch average age for each gender ===== | ||
+ | |||
+ | <code sql> | ||
+ | SELECT AVG(age) | ||
+ | FROM Students | ||
+ | GROUP BY gender; | ||
+ | </ | ||
+ | |||
+ | ---- | ||
- | [[SQL: |
sql/select.1657269722.txt.gz · Last modified: 2022/07/08 08:42 by 185.192.71.135