0% found this document useful (0 votes)
31 views9 pages

IM 101 - Fundamentals of Database Systems - Unit 14

Uploaded by

ceemorgan91
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
31 views9 pages

IM 101 - Fundamentals of Database Systems - Unit 14

Uploaded by

ceemorgan91
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 9

Copyright © 2020 by the Pamantasan ng Lungsod ng Valenzuela

All rights reserved. No part of this module may be reproduced, repurposed, distributed, or transmitted in
any form or by any means including photocopying, reprinting, or other electronic or mechanical
methods without the prior written permission of PLV and the individual developers of instructional
materials (IMs) except in the case of brief quotations embodied in critical and creative reviews and
certain other noncommercial uses permitted by the Copyright Law. For permission request, address your
written correspondence whether printed or electronic to the Chair of the University Committee on
Instructional Materials Development and Evaluation at the address below:

Pamantasan ng Lungsod ng Valenzuela


Tongco St., Maysan, Valenzuela City
College: Department: Course Course Title:
Engineering and Information Information Code: Fundamentals of Database
Technology Technology IM 101 Systems
Faculty: Chairperson:
Rommel P. Apostol, MIT PATRICK LUIS M. FRANCISCO, MIT

Understanding the Flow of Data in Everyday Transactions,


A module in IM 101: Fundamentals of Database Systems
Foreword
This module aims to help students understand, familiarize, and adopt the use of fundamental data
processes and operation to utilize them in developing more efficient and secure information systems.
This module contains lessons that introduce them to the core concept of database systems and
management and answers the essential questions presented in each part of the module. The learning
outcomes from each part of the module will help the students understand the essential questions given
and at a certain point in the discussions, an evaluation will be done through the use of different
activities.
At the end of this module, the student will be able to understand the basic concepts and use of
database systems and be able to use tools and software in manipulating them.
Table of Contents
Unit Fourteen
Essential Questions …………………………………………………………………………….. 1
Intended Learning Outcomes …………………………………………………………………... 1
Assesment Task
Diagnostic ………………………………………………………………………………. 1
Formative ……………………………………………………………………………….. 3
Summative ………………………………………………………………………….…... 3
Lessons Input …………………………………………………………………………………… 1
References ………………………………………………………………………………….…… 4
1

Unit Fourteen – Using Order by Clause and Aggregate Functions


This unit introduces the order by clause and aggregate functions, their uses and how they can be applied
when creating queries in a database.

 Essential Question
How do we order results in a query ?
What are aggregate functions ?
How are aggregate functions used ?

 Intended Learning Outcomes


Ordering the results of an SQL query

The types and application of aggregate functions

 Diagnostic Assessment Task


At the start of the lesson the instructor will provide the following activities to gauge the students
understanding of the lesson beforehand :
1. The instructor will give two to three transactions to students involving order by clause and
aggregate functions

 Lessons Input
Ordering a List
ORDER BY clause is especially useful when the listing order is important to you. Sample syntax is :
SELECT columnlist
FROM tablename
[WHERE condition]
ORDER BY columnname ASC/DESC

Example we want to order all information in tbl_Name according to FIRST_NAME:


SELECT * FROM Person

ORDER BY FirstName
2

--default order is ascending,

if we want to sort descending we use:


SELECT * FROM Person
ORDER BY FirstName DESC

We can also order using multiple column name with the column name being followed from left to right
SELECT * FROM Person
ORDER BY LastName, FirstName, MiddleName
--orders the data by last name, first name and middle name

DISTINCT clause produces a list of only those values that are different from one another. For example,
we want to get the list of all the unique Last name from the Person we can do :
SELECT DISTINCT LastName FROM Person

Aggregate Functions

Figure 14.1 Aggregate functions

COUNT function is used to tally the number of non-null values of an attribute. COUNT can be used in
conjunction with the DISTINCT clause. Example:
SELECT COUNT(DISTINCT LastName) FROM Person
--counts all distinct Last Name from Person

MIN and MAX example:

SELECT MIN(PRICE) FROM tbl_Product


--displays lowest value for PRICE in tbl_Product
SELECT MAX(PRICE) FROM tbl_Product
3

--displays highest value for PRICE in tbl_Product

SUM example :
SELECT SUM(SALES) FROM tbl_Product
--add up all the values from SALES column
AVG example :
SELECT AVG(SALES) FROM tbl_Product
--gets the average of all the values from SALES column

Take note that SUM and AVG must be used for numeric values only.

 Formative Assessment Task


1. Ask students to write down what they perceived as the muddiest point in a lecture, reading,
etc. The muddiest point is something that they still do not fully understand, or are having
difficulty with. Collect responses then clarify these muddy points during the next class.

*** End of Lesson Input ***

 Summative Assessment Task


2. The instructor will give two to three transactions to students involving order by clause and
aggregate functions
4

References

Garcia-Molina, H.,Ullman, J.,Widom, J. (2008). Database Systems: The Complete Book (2nd ed., pp 189-
501). Pearson

You might also like