sql:select
Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
sql:select [2022/07/08 08:38] – created 185.192.71.135 | sql:select [2022/07/08 09:12] (current) – 185.92.25.28 | ||
---|---|---|---|
Line 4: | Line 4: | ||
<code sql> | <code sql> | ||
- | SELECT * from Students; | + | SELECT * FROM Students; |
</ | </ | ||
---- | ---- | ||
+ | |||
+ | ===== Fetch maximum 10 rows from a table ===== | ||
+ | |||
+ | <code sql> | ||
+ | SELECT fname, lname FROM Students | ||
+ | LIMIT 10; | ||
+ | </ | ||
---- | ---- | ||
- | [[SQL: | + | ===== Fetch specific columns |
- | [[SQL:SELECT:Fetch maximum 10 rows from a table|Fetch maximum 10 rows from a table]] | + | <code sql> |
+ | SELECT | ||
+ | </ | ||
- | [[SQL:SELECT:Fetch selected columns | + | ---- |
+ | |||
+ | ===== Filter data from a table ===== | ||
+ | |||
+ | <code sql> | ||
+ | SELECT | ||
+ | WHERE rollno > 1234; | ||
+ | </ | ||
+ | |||
+ | |||
+ | ---- | ||
+ | |||
+ | ===== Fetch from two tables ===== | ||
+ | |||
+ | <code sql> | ||
+ | SELECT fname, lname FROM Students | ||
+ | INNER JOIN Teachers | ||
+ | ON Students.teacher = Teacher.no | ||
+ | </ | ||
+ | |||
+ | ---- | ||
+ | |||
+ | ===== Fetch maximum age from a table ===== | ||
+ | |||
+ | <code sql> | ||
+ | SELECT MAX(age) | ||
+ | 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.1657269535.txt.gz · Last modified: 2022/07/08 08:38 by 185.192.71.135