User Tools

Site Tools


sql:select

SQL - SELECT

Fetch all data from a table

SELECT * FROM Students;

Fetch maximum 10 rows from a table

SELECT fname, lname FROM Students
LIMIT 10;

Fetch specific columns from a table

SELECT fname, lname FROM Students;

Filter data from a table

SELECT fname, lname FROM Students
WHERE rollno > 1234;

Fetch from two tables

SELECT fname, lname FROM Students
INNER JOIN Teachers
ON Students.teacher = Teacher.no

Fetch maximum age from a table

SELECT MAX(age)
FROM Students;

Fetch minimum age from a table

SELECT MIN(age)
FROM Students;

Fetch sum of ages from a table

SELECT SUM(age)
FROM Students;

Fetch average age from a table

SELECT AVG(age)
FROM Students;

Fetch average age for each gender

SELECT AVG(age)
FROM Students
GROUP BY gender;

sql/select.txt · Last modified: 2022/07/08 10:12 by 185.92.25.28

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki