lec10.365

Lec10.365 - Fall 2007 CPE/CSC 365 Introduction to Database Systems Alexander Dekhtyar SQL Structured Query Language Grouping Queries SQL SELECT

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 Grouping Queries SQL SELECT statement has two more clauses to support grouping opera- tions: GROUP BY and HAVING clauses. GROUP BY Clause The syntax of a GROUP BY clause is GROUP BY <AttributeName>,. ..,<AttributeName> The GROUP BY clause is added to the SELECT statement after the WHERE clause (or, if there is no WHERE clause, after the FROM clause. GROUP BY clause causes the DBMS to separate the cartesian product of all tables referenced in the FROM clause into groups of tuples. Each group of tuples must agree on all values of attributes listed in the GROUP BY clause Grouping operation is used to allow for computation and reporting of aggregate operations over groups in the SELECT statement. Consider, for example the relational table Student(FirstName, LastName, GPA, Class, Grade, School) The following query SELECT School, COUNT(*) FROM Student GROUP BY School; will output the number of students enrolled in each school.
Background image of page 1

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

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

This note was uploaded on 05/19/2008 for the course CSC 365 taught by Professor Dekhtyar during the Spring '08 term at Cal Poly.

Page1 / 2

Lec10.365 - Fall 2007 CPE/CSC 365 Introduction to Database Systems Alexander Dekhtyar SQL Structured Query Language Grouping Queries SQL SELECT

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