Xin 2010-11-01.  Syntax ◦ SELECT field1 AS title1, field2 AS title2,... ◦ FROM table1, table2 ◦ WHERE conditions  Make a query that returns all records.

Slides:



Advertisements
Similar presentations
SQL Database for a Book Store Clinton McKay. Explanation The database contains information about the books held in stock, their authors, publishers, customers,
Advertisements

CS 3630 Database Design and Implementation. Where Clause and Aggregate Functions -- List all rooms whose price is greater than the -- average room price.
CPSC 203 Introduction to Computers Lab 23 By Jie Gao.
Exploring Microsoft Access
Concepts of Database Management Seventh Edition
Concepts of Database Management Sixth Edition
Concepts of Database Management Seventh Edition
Copyright  Oracle Corporation, All rights reserved. 5 Aggregating Data Using Group Functions.
1Eyad alshareef Enhanced Guide to Oracle 10g Chapter 3: Using SQL Queries to Insert, Update, Delete, and View Data.
GROUP FUNCTIONS. Objectives After completing this lesson, you should be able to do the following: Identify the available group functions Describe the.
Using Relational Databases and SQL Steven Emory Department of Computer Science California State University, Los Angeles Lecture 7: Aggregates.
The University of Akron Dept of Business Technology Computer Information Systems The Relational Model: Query-By-Example (QBE) 2440: 180 Database Concepts.
Using Relational Databases and SQL Steven Emory Department of Computer Science California State University, Los Angeles Lecture 6: Set Functions.
Week 2 Normalization and Queries
Using Relational Databases and SQL Steven Emory Department of Computer Science California State University, Los Angeles Lecture 7: Aggregates.
Using Relational Databases and SQL Steven Emory Department of Computer Science California State University, Los Angeles Lecture 5: Subqueries and Set Operations.
Mark Dixon Page 1 02 – Queries: Query by Example.
LSP 121 Week 2 Normalization and Queries. Normalization The Old Car Club database presented a problem – what if one person owns multiple cars? (One owner.
Microsoft Access 2010 Chapter 7 Using SQL.
Computer Science 101 Web Access to Databases SQL – Extended Form.
Exploring Office Grauer and Barber 1 Information From the Database: Reports and Queries(Wk4)
Concepts of Database Management, Fifth Edition
Relational DBs and SQL Designing Your Web Database (Ch. 8) → Creating and Working with a MySQL Database (Ch. 9, 10) 1.
Microsoft Access 2010 Chapter 7 Using SQL. Change the font or font size for SQL queries Create SQL queries Include fields in SQL queries Include simple.
SQL/lesson 2/Slide 1 of 45 Retrieving Result Sets Objectives In this lesson, you will learn to: * Use wildcards * Use the IS NULL and IS NOT NULL keywords.
Concepts of Database Management Seventh Edition
Using Special Operators (LIKE and IN)
Copyright س Oracle Corporation, All rights reserved. 5 Aggregating Data Using Group Functions.
Exploring Office Grauer and Barber 1 Committed to Shaping the Next Generation of IT Experts. Chapter 3 - Information From the Database: Reports.
Querying a Database - A question or an inquiry (dictionary.com) - WHAT ARE WE ASKING QUESTIONS ABOUT? THE DATA - BY ASKING QUESTIONS OF THE DATA WE OBTAIN?
SQL-5 (Group By.. Having). Group By  Need: To apply the aggregate functions to subgroups of tuples in a relation, where the subgroups are based on some.
Intro to SQL Management Studio. Please Be Sure!! Make sure that your access is read only. If it isn’t, you have the potential to change data within your.
Chapter 3 Query and Report. Agenda Report types Report contents Report creation Report design view Query and dynaset Function and grouping Action query.
26 Mar 04 1 Application Software Practical 5/6 MS Access.
What are queries? Queries are a way of searching for and compiling data from one or more tables. Running a query is like asking a detailed question of.
In this session, you will learn to: Use functions to customize the result set Summarize and group data Objectives.
Set Analysis. Agenda 1. What is Set Analysis? 2. Why do we use it? 3. How do we use it (syntax)? 4. Examples.
Concepts of Database Management Seventh Edition Chapter 3 The Relational Model 2: SQL.
1 MS Access. 2 Database – collection of related data Relational Database Management System (RDBMS) – software that uses related data stored in different.
Structured Query Language SQL Unit 4 Solving Problems with SQL.
Aggregating Data Using Group Functions. Objectives After completing this lesson, you should be able to do the following: –Identify the available group.
A am going to create a table in design view. I am going to create a table in an Access database that contains information about the books that I have on.
April 2002 Information Systems Design John Ogden & John Wordsworth 1 Database Design SQL (1) John Wordsworth Department of Computer Science The University.
Lesson 4: Querying a Database. 2 Learning Objectives After studying this lesson, you will be able to:  Create, save, and run select queries  Set query.
Sorting data and Other selection Techniques Ordering data results Allows us to view our data in a more meaningful way. Rather than just a list of raw.
SQL LANGUAGE TUTORIAL Prof: Dr. Shu-Ching Chen TA: Hsin-Yu Ha.
Computer Science & Engineering 2111 Inner Joins and Advanced Queries 1CSE 2111 Lecture-Advanced Queries.
Concepts of Database Management, Fifth Edition Chapter 3: The Relational Model 2: SQL.
Relational Databases Today we will look at: Different ways of searching a database Creating queries Aggregate Queries More complex queries involving different.
Structured Query Language used for defining and manipulating data in Relational DBs aimed at: –reducing training costs –increasing productivity –improve.
Aggregating Data Using Group Functions
Aggregating Data Using Group Functions
(SQL) Aggregating Data Using Group Functions
MENAMPILKAN DATA DARI SATU TABEL (Chap 2)
SQL – Entire Select.
Aggregating Data Using Group Functions
Access: SQL Participation Project
MongoDB Aggregations.
MongoDB Aggregations.
CS122 Using Relational Databases and SQL
M1G Introduction to Database Development
Query Functions.
Section 4 - Sorting/Functions
Projecting output in MySql
MongoDB Aggregations.
Aggregate Functions.
LINQ to SQL Part 3.
Chapter 3 Query and Report.
Presentation transcript:

Xin

 Syntax ◦ SELECT field1 AS title1, field2 AS title2,... ◦ FROM table1, table2 ◦ WHERE conditions  Make a query that returns all records from a table  Create a query that shows (1) title name and (2) type from bktblTitles  Create a query that displays (1) title name along with (2) book’s publisher and (3) its author’s last name.

 Functions ◦ Set conditions for retrieved records  Similar to criteria in Design View ◦ Build relationships between tables  Practice ◦ Create a query that returns the titles of “biography” books ◦ Create a query that displays (1) title name along with (2) book’s publisher and (3) its author’s last name. Ensure that each record is correct. ◦ Create a query that displays (1) book title ID, (2) book title name, (3) publisher’s name, and (4) author’s last name. Only show California published entries.

 Aggregate functions ◦ Avg, count, min, max,...  Practices ◦ Create a query to compute the total and average sales  GROUP BY clause  Practices ◦ Modify the just created query, so that it shows the total and average sales of books of each type  HAVING clause ◦ Set conditions to results of aggregate functions  In comparison, WHERE  individual records ◦ Must work with GROUP BY ◦ Example  SELECT type, AVG(sales) AS AvgOfsales  FROM bktblTitles  WHERE pages>100  GROUP BY bktblTitles.type  HAVING SUM(sales)>100000;

 Practices ◦ Create a query that displays the # of books each publisher has published. ◦ Modify the query, so that it includes records of books with authors living in “NY”. Only groups of records with page numbers of titles greater than 100.