SQL Foundations I Module 2

Use aggregate functions in query

Only editable by group admins

  • Last updated August 24, 2016 at 1:05 PM
  • Evidence visible to public
Four queries will utilize aggregate functions (each query must use a different function). Provide a link to your work.

All posted evidence

Aggregate Function It passed!

SELECT id, count(*) from grade group by id having count(*) > 1; SELECT creditsearned, count(*) from student group by student_id; SELECT creditsearned, max(creditsearned) from student group by student_name; SELECT salary, sum(salary) from teacher group by name; 

https://parkland1-my.sharepoint.com/:w:/r/personal/sdow3_stu_parkland_edu/_layouts/15/Doc.aspx?sourcedoc=%7B49198A6F-18AB-40C0-BF1C-94B3CD5DF86B%7D&file=Module%202_%20CSC176%20Data%20Systems_Sharon%20Dow%20102318.docx&action=default&mobileredirect=true


sdow3 About 7 years ago

(Hopefully) Final tweaks

mpurnell1 About 8 years ago

4 tweaked aggregate function queries

Query 4

mpurnell1 About 8 years ago

Query 3

mpurnell1 About 8 years ago

Query 2

mpurnell1 About 8 years ago

Query 1

mpurnell1 About 8 years ago

Results for All 4 Queries

jmfisher About 8 years ago

Statements for Aggregate Functions

/*Query 1 - Total cost of all Signs*/
SELECT ROUND(SUM(cost),2) AS 'Total Cost' FROM Signs;
/*Query 2 - Average cost of all Signs*/
SELECT ROUND(AVG((cost/quantity)), 2) AS 'Average Cost per Sign' FROM Signs;
/*Query 3 - Maximum Sqr Footage from list of signs*/
SELECT MAX(hor_dimens * vert_dimens) AS 'Most Sqr Ftg' FROM Signs;
/*Query 4 - Lowest price of any one sign from list*/
SELECT ROUND(MIN(cost/quantity),2) AS 'Lowest Priced Sign' FROM Signs;
jmfisher About 8 years ago

Returning the average value from a numeric column, represented by year_released. AS referring to an alias.

SELECT COUNT(*)
FROM people

SELECT AVG(year_released) as average_us_year
FROM movies
WHERE country = 'us'

SELECT MIN(year_released) as earliest_year
FROM movies

SELECT MAX(year_released) as latest_year
FROM movies
vbecu1 Almost 9 years ago

The ROUNDed AVERAGE number of bytes for each type of file.

jaco Almost 9 years ago

Finds the largest and smallest filesizes in each directory with MIN and MAX.

jaco Almost 9 years ago