User Tools

Site Tools


sql:select

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
sql:select [2022/07/08 08:57] 185.92.25.28sql:select [2022/07/08 09:12] (current) 185.92.25.28
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 fname, lname FROM Students 
 +INNER JOIN Teachers 
 +ON Students.teacher = Teacher.no 
 +</code>
  
-[[SQL:SELECT:Fetch maximum 10 rows from a table|Fetch maximum 10 rows from a table]]+----
  
-[[SQL:SELECT:Fetch selected columns from a table|Fetch selected columns from a table]]+===== Fetch maximum age from a table ===== 
 + 
 +<code sql> 
 +SELECT MAX(age) 
 +FROM Students; 
 +</code> 
 + 
 +---- 
 + 
 +===== Fetch minimum age from a table ===== 
 + 
 +<code sql> 
 +SELECT MIN(age) 
 +FROM Students; 
 +</code> 
 + 
 +---- 
 + 
 +===== Fetch sum of ages from a table ===== 
 + 
 +<code sql> 
 +SELECT SUM(age) 
 +FROM Students; 
 +</code> 
 + 
 +---- 
 + 
 +===== Fetch average age from a table ===== 
 + 
 +<code sql> 
 +SELECT AVG(age) 
 +FROM Students; 
 +</code> 
 + 
 +---- 
 + 
 +===== Fetch average age for each gender ===== 
 + 
 +<code sql> 
 +SELECT AVG(age) 
 +FROM Students 
 +GROUP BY gender; 
 +</code> 
 + 
 +----
  
-[[SQL:SELECT:Filter data from a table|Filter data from a table]] 
sql/select.1657270644.txt.gz · Last modified: 2022/07/08 08:57 by 185.92.25.28

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki