





















Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
An overview of various sql select statements, including order by for sorting results, using constants and arithmetic expressions, evaluating aggregate functions, and applying the group by clause for grouping and aggregating data. Examples and syntax are provided for each concept.
Typology: Slides
1 / 29
This page cannot be seen from the preview
Don't miss anything!






















Grades
Name Code Mark
John DBS 56 John IAI 72 Mary DBS 60 Mark PR1 43 Mark PR2 35 Jane IAI 54
Name Code Mark Mary DBS 60 John DBS 56 John IAI 72 Jane IAI 54 Mark PR1 43 Mark PR2 35
SELECT Mark/ FROM Grades
Salary + Bonus FROM Employee
SELECT 1.175Price FROM Products*
Grades
Name Code Mark
John DBS 56 John IAI 72 Mary DBS 60 Mark PR1 43 Mark PR2 35 Jane IAI 54
COUNT() AS Count FROM Grades*
SUM(Mark) AS Total FROM Grades
MAX(Mark) AS Best FROM Grades
Count 6
Total 320
Best 72
MAX(Mark)-MIN(Mark) AS Range FROM Grades Grades Name Code Mark John DBS 56 John IAI 72 Mary DBS 60 Mark PR1 43 Mark PR2 35 Jane IAI 54
Range 37
MAX(Mark) = 72
MIN(Mark) = 35
Month Department Value
March Fiction 20 March Travel 30 March Technical 40 April Fiction 10 April Fiction 30 April Travel 25 April Fiction 20 May Fiction 20 May Technical 50
Sales
Month Department Total
April Fiction 60 April Travel 25 March Fiction 20 March Technical 40 March Travel 30 May Fiction 20 May Technical 50
SELECT Month, Department, SUM(Value) AS Total FROM Sales GROUP BY Month, Department Month Department Total April Fiction 60 March Fiction 20 May Fiction 20 March Technical 40 May Technical 50 April Travel 25 March Travel 30
SELECT Month, Department, SUM(Value) AS Total FROM Sales GROUP BY Department, Month
SELECT Name,
AVG(Mark) AS Average FROM Grades GROUP BY Name
SELECT ‘Total’ AS Name, AVG(Mark) AS Average FROM Grades
Name Average Jane 52 John 64 Mark 39 Mary 60 Total 53