Kirkwood Center for Continuing Education Introduction to PHP and MySQL By Fred McClurg, Copyright © 2010 All Rights Reserved. 1.

Slides:



Advertisements
Similar presentations
Functions S S T : S P R E A D S H E E T S SST 5 Spreadsheet 5 Function.
Advertisements

Database Programming Sections 5 & 6 – Group functions, COUNT, DISTINCT, NVL, GROUP BY, HAVING clauses, Subqueries.
4 Copyright © 2004, Oracle. All rights reserved. Reporting Aggregated Data Using the Group Functions.
5 Copyright © Oracle Corporation, All rights reserved. Aggregating Data Using Group Functions.
5 Copyright © 2007, Oracle. All rights reserved. Reporting Aggregated Data Using the Group Functions.
5 Copyright © Oracle Corporation, All rights reserved. Aggregating Data Using Group Functions.
4 การใช้ SQL Functions. Copyright © 2007, Oracle. All rights reserved What Are Group Functions? Group functions operate on sets of rows to give.
Chapter 11 Group Functions
After completing this lesson, you should be able to do the following: Identify the available group functions Describe the use of group functions Group.
LECTURE 10.  Group functions operate on sets of rows to give one result per group.
Kirkwood Center for Continuing Education Introduction to PHP and MySQL By Fred McClurg, © Copyright 2010 All Rights Reserved.
Kirkwood Center for Continuing Education Introduction to PHP and MySQL By Fred McClurg, © Copyright 2010 All Rights Reserved. 1.
Kirkwood Center for Continuing Education Introduction to PHP and MySQL By Fred McClurg, Copyright © 2014 All Rights Reserved.
Kirkwood Center for Continuing Education Introduction to PHP and MySQL By Fred McClurg, © Copyright 2014 All Rights Reserved.
Kirkwood Center for Continuing Education Introduction to PHP and MySQL By Fred McClurg, Copyright © 2010 All Rights Reserved. 1.
Kirkwood Center for Continuing Education Introduction to PHP and MySQL By Fred McClurg, Copyright © 2014 All Rights Reserved.
Kirkwood Center for Continuing Education Introduction to PHP and MySQL By Fred McClurg, © Copyright 2010 All Rights Reserved. 1.
Kirkwood Center for Continuing Education Introduction to PHP and MySQL By Fred McClurg, Copyright © 2010 All Rights Reserved.
Introduction to Oracle9i: SQL1 SQL Group Functions.
Introduction to PHP and MySQL Kirkwood Center for Continuing Education By Fred McClurg, © Copyright 2010, All Rights Reserved.
Introduction to PHP and MySQL Kirkwood Center for Continuing Education By Fred McClurg, © Copyright 2014, Fred McClurg, All Rights.
Kirkwood Center for Continuing Education Introduction to PHP and MySQL By Fred McClurg, Copyright © 2010 All Rights Reserved. 1.
Kirkwood Center for Continuing Education Introduction to PHP and MySQL By Fred McClurg, Copyright © 2010 All Rights Reserved.
Kirkwood Center for Continuing Education By Fred McClurg, Introduction to PHP and MySQL Copyright © 2010 All Rights Reserved.
Measuring Time.
Chapter 6 Group Functions. Chapter Objectives  Differentiate between single-row and multiple-row functions  Use the SUM and AVG functions for numeric.
Agenda TMA01 M876 Block 3 – Using SQL Structured Query Language - SQL A non-procedural language to –Create database and relation structures. –Perform.
4 Copyright © 2004, Oracle. All rights reserved. Reporting Aggregated Data Using the Group Functions.
After completing this lesson, you should be able to do the following: Describe various types of functions available in MySQL Use character, number, and.
5 Copyright © Oracle Corporation, All rights reserved. Aggregating Data Using Group Functions.
Structured Query Language. Group Functions What are group functions ? Group Functions Group functions operate on sets of rows to give one result per group.
Chapter 11 Functions and Groups Part C. SQL Copyright 2005 Radian Publishing Co.
Comp12 cont…. Using Quotes Note that we have used single quotes around the conditional values in the examples. SQL uses single quotes around text values.
Advanced SELECT Queries CS 146. Review: Retrieving Data From a Single Table Syntax: Limitation: Retrieves "raw" data Note the default formats… SELECT.
Basic Group Functions (without GROUP BY clause) Week 5 – Chapter 5.
IST 210 SQL Todd Bacastow IST 210: Organization of Data.
1 Querying a Single Table Structured Query Language (SQL) - Part II.
Queries SELECT [DISTINCT] FROM ( { }| ),... [WHERE ] [GROUP BY [HAVING ]] [ORDER BY [ ],...]
Retrieving Data Using the SQL SELECT Statement. Objectives After completing this lesson, you should be able to do the following: – List the capabilities.
DATA RETRIEVAL WITH SQL Goal: To issue a database query using the SELECT command.
Kirkwood Center for Continuing Education Introduction to PHP and MySQL By Fred McClurg, © Copyright 2015, Fred McClurg, All Rights.
SQL Aggregation Oracle and ANSI Standard SQL Lecture 9.
Introduction to Functions – Single Row Functions.
CS 111 – Nov. 8 Databases Database Management Systems (DBMS) Structured Query Language (SQL) Commitment –Please review sections 9.1 – 9.2.
Single-Table Queries 2: Advanced Topics CS 320. Review: Retrieving Data From a Single Table Syntax: Limitation: Retrieves "raw" data SELECT field1, field2,
Agenda for Class - 03/04/2014 Answer questions about HW#5 and HW#6 Review query syntax. Discuss group functions and summary output with the GROUP BY statement.
Aggregating Data Using Group Functions. What Are Group Functions? Group functions operate on sets of rows to give one result per group.
SQL Aggregeringsfunktioner. AGGREGATE FUNCTIONS Include COUNT, SUM, MAX, MIN, and AVG Query 15: Find the maximum salary, the minimum salary, and the average.
Kirkwood Center for Continuing Education Introduction to PHP and MySQL By Fred McClurg, Copyright © 2016, Fred McClurg, All Rights.
5-1 Copyright © 2004, Oracle. All rights reserved. DISPLAYING DATA FROM MULTIPLE TABLES OUTER JOIN.
SQL AGGREGATE FUNCTIONS
Chapter 3 Introduction to SQL(3)
Working with Tables: Join, Functions and Grouping
Kirkwood Center for Continuing Education
Chapter 11 Functions and Groups
Aggregating Data Using Group Functions
4.01 Spreadsheet Formulas & Functions
Kirkwood Center for Continuing Education
4.01 Spreadsheet Formulas & Functions
Reporting Aggregated Data Using the Group Functions
Query Functions.
Reporting Aggregated Data Using the Group Functions
Kirkwood Center for Continuing Education
Aggregate Functions.
Reporting Aggregated Data Using the Group Functions
Lab 3: Single-row Functions
Aggregate functions Objective- understand and able to use aggregate functions in select statement Aggregate functions are used to implement calculation.
分组函数 Schedule: Timing Topic 35 minutes Lecture 40 minutes Practice
Chapter Name SQL: Data Manipulation
Aggregating Data Using Group Functions
Presentation transcript:

Kirkwood Center for Continuing Education Introduction to PHP and MySQL By Fred McClurg, Copyright © 2010 All Rights Reserved. 1

Chapter Eight MySQL Time/Date Functions 2 urses/php/slides/chapter08d.functions.ppt

Functions return the current time and date. NOW() SYSDATE() CURRENT_TIMESTAMP() Example: SELECT NOW(); SELECT SYSDATE(); SELECT CURRENT_TIMESTAMP(); Date and Time Functions 3

Date and Time Functions (cont.) 4

DATE_FORMAT() Displays the date in the format specified. Example: SELECT DATE_FORMAT( NOW(), '%M %d, %Y %h:%i:%s %p'); Date Format Function 5

Date Format Specifier Characters (1) SpecifierDescription %a Abbreviated weekday name (Sun..Sat) %b Abbreviated month name (Jan..Dec) %c Month, numeric (0..12) %D Day of the month with English suffix (1st, 2nd, 3rd, …) %d Day of the month, numeric (00..31) %e Day of the month, numeric (0..31) %f Microseconds ( ) %H Hour (00..23) %h Hour (01..12) %I Hour (01..12) 6

Date Format Specifier Characters (2) SpecifierDescription %i Minutes, numeric (00..59) %j Day of year ( ) %k Hour (0..23) %l Hour (1..12) %M Month name (January..December) %m Month, numeric (00..12) %p AM or PM %r Time, 12-hour (hh:mm:ss with AM or PM) %S Seconds (00..59) %s Seconds (00..59) 7

Date Format Specifier Characters (3) SpecifierDescription %T Time, 24-hour (hh:mm:ss) %U Week (00..53), where Sunday is the first day of the week %V Week (01..53), where Sunday is the first day of the week; used with %X %W Weekday name (Sunday..Saturday) %w Day of the week (0=Sunday..6=Saturday) %X Year for week where Sunday is first day of week, numeric, four digits; used with %V %Y Year, numeric, four digits %y Year, numeric (two digits) % A literal “%” character 8

Chapter Eight Other Common MySQL Functions 9

MIN(): Finds the minimum value for a column. MAX(): Finds the maximum value for a column. Example: SELECT MIN(salary) AS Poor, MAX(salary) AS Rich FROM paystub; Note: “Poor” and “Rich” are aliases for “MIN(salary)” and “MAX(salary)”. SQL Functions: MIN and MAX 10

COUNT(): Finds the number of data rows. Example: SELECT COUNT(id) AS tally FROM recipe; Note: “tally” is an alias for “COUNT(id)”. SQL Function: COUNT 11

SUM(): Finds the total value of a column. Example: SELECT SUM(salary) AS Total FROM paystub; Note: “Total is an alias for “SUM(salary)”. Other SQL Function: SUM 12

AVG(): Finds the average value for a column. Example: SELECT AVG(salary) AS Average FROM paystub; Note: “Average” is an alias for “AVG(salary)”. Other SQL Function: AVG 13

to be continued... urses/php/slides/chapter09a.dataTypes.ppt