lec09.365

lec09.365 - returns the average of the Salary Feld in a...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
. . Fall 2007 CPE/CSC 365: Introduction to Database Systems Alexander Dekhtyar . . SQL: Structured Query Language Aggregate Operations Aggregate Operations Aggregate database operations are operations that return individual values ( ag- gregates ) instead of tuples. These aggregates can be used in the SELECT clause of the SELECT statement. There are Fve aggregate operations in SQL: Aggregate Operation Explanation COUNT() returns the number of rows AVG() returns the average value in the column MIN() returns the minimum value in the column MAX() returns the maximum value in the column SUM() returns the sum of the values in the column AVG,SUM,MAX,MIN. ±or the AVG, SUM, MAX and MIN operations the syntax is AVG(<ColumnName>) SUM(<ColumnName>) MAX(<ColumnName>) MIN(<ColumnName>) Here, <ColumnName> is expected be of a numeric type. E.g. SELECT AVG(Salary) FROM Employee;
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: returns the average of the Salary Feld in a relation Employee(ID, Name, Salary, Dept) . COUNT. COUNT has more interesting syntax. The two traditional forms of the COUNT() operator are COUNT(*) COUNT([DISTINCT] &lt;ColumnName&gt;) 1 COUNT(*) form counts the number of tuples returned by the rest of the query. SELECT COUNT(*) FROM Employee; returns the number of employee records. Similar result can be achieved by replacing * with an column name: SELECT COUNT(Name) FROM Employee; returns the same result as the previous query. DISTINCT qualiFer allows us to count only unique values found in the column: SELECT COUNT(DISTINCT Salary) FROM Employee; returns the number of dierent salary levels recorded in the Employee table. 2...
View Full Document

Page1 / 2

lec09.365 - returns the average of the Salary Feld in a...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online