Instructor: Craig Duckett. Lecture 03: Tuesday, April 3, 2018 SQL Sorting, Aggregates and Joining Tables

Size: px
Start display at page:

Download "Instructor: Craig Duckett. Lecture 03: Tuesday, April 3, 2018 SQL Sorting, Aggregates and Joining Tables"

Transcription

1 Instructor: Craig Duckett Lecture 03: Tuesday, April 3, 2018 SQL Sorting, Aggregates and Joining Tables 1

2 Assignment 1 is due LECTURE 5, Tuesday, April 10 th, 2018 in StudentTracker by MIDNIGHT MID-TERM EXAM is LECTURE 10, Tuesday, May 1 st, 2018 Assignment 2 is due LECTURE 12, Tuesday, May 8 th, 2018 in StudentTracker by MIDNIGHT 2

3 3 x 150 Points (450 points Total) Assignment 1 (Stage 1): DUE LECTURE 5 Tuesday, April 10 th Assignment 2 (Stage 2): DUE LECTURE 12 Tuesday, May 8 th Assignment 3 (Stage 3): DUE LECTURE 20 Tuesday, June 5 th Database Presentation: DUE LECTURE 20 Tuesday, June 5 th 3

4 Tuesday (LECTURE 3) Database Design for Mere Mortals: Chapter 2 Thursday (LECTURE 4) The Language of SQL: Chapter 3: Calculations and Aliases Chapter 4: Using Functions 4

5 SQL Sorting (Sort Query Results) SQL Aggregate Functions SQL Joining Tables In-Class Exercises Working with XAMPP SQL Queries 5

6 SQL Sorting (Sort Query Results) The way that the database will return the results of your query is not always what you want, so let's see how to sort those results. In this simple example I have a Product table in my database, and I've got a very straightforward SELECT statement that's going to select three of the columns Description, ListPrice, and Color from the Product table, meaning, give me all the rows. I haven't even applied a WHERE clause on this. So, get everything returned whether that's a thousand rows or a million rows, but there will be no inherent order in these. The way that they are going to be returned is currently more to do with the internal structure of the database. Now, it doesn't necessarily match what I might find most useful.

7 SQL Sorting (Sort Query Results) Let's say what I want to do is find out the most expensive products that I have. I would get that data in my results, but not presented to me in an easy to scan way. I'd like to see most expensive first, cheapest last. And I can do this with another optional keyword in an SQL query, which I'll put right at the end of this statement after the FROM clause. So, I'm going to add the keyword Order By, and it is written as two separate words. The question is Order By what?

8 SQL Sorting (Sort Query Results) In this case, I'd like to order by the values in the column called, ListPrice, whatever those values are. So, I'll use the name of that column, ORDER BY ListPrice. Now by default, ordering is in ascending order, which would mean the row with the smallest ListPrice would be arranged first.

9 SQL Sorting (Sort Query Results) If I want to order by the most expensive first, I need to make this descending order and to do that, I just type in the word DESC afterwards. There is an ASC keyword for ascending, but ascending is the default. The results of these will come back, and this time around, it's going to bring back the same number of rows, but it will order them by ListPrice descending.

10 SQL Sorting (Sort Query Results) Now you can also pick multiple columns to ORDER BY. So if in this example, I was writing a simple SELECT statement to select all the rows from the Employee table, in this case where a Salary is greater than 50,000, because we can do WHERE clause as well as an ORDER BY. I'll do an Order By LastName, FirstName. I didn't use the word DESC or ASC, so they're both going to be ascending. So, the results will come back, again, it doesn't matter how many rows they were. We're going to first be ordering by LastName all the way through these results. But then wherever the LastName is the same, we're going to do a sub ordering within it and in this case we'll order by FirstName. So as you see a very simple format to start to impose some kind of structure on the results you're getting back in your query.

11 Next up, we have a few more SQL keywords to work with and these are all grouped under the term aggregate functions, which doesn't really suggest how useful they can be. An aggregate or grouping function means it will perform some kind of calculation on a set of data that we describe, but return a single value. Now, what that single value is depends on which aggregate function we use.

12 Aggregate Functions We've seen already how we can do a simple SELECT statement like this one, and this will return everything, all our columns, all our rows, whether that's five employee rows or 5,000 or 500,000. But what if that number itself was the piece of information I wanted? What if I just wanted you to know how many rows are in this table? I don't need anything else. I just want to know how many rows. Well, I can do that by using an Aggregate function in SQL called Count.

13 Aggregate Functions And what I'm going to do is just change the SELECT * to SELECT COUNT (*). Count everything in the Employee table. If I execute this, it will COUNT all the rows and just return a single value just, in this case 547.

14 Aggregate Functions Now, you could of course use a WHERE clause if you wanted to restrict the results to just counting the number of employee rows that have a Salary greater than 5,000, we get a different result. That is all COUNT will do for you is just COUNT the number of rows for this particular condition.

15 Aggregate Functions Now sometimes, however, the COUNT isn't what you want. In the previous topic on Sorting, I used the example of selecting Products and using the Order By clause to sort them by, in this case ListPrice descending. But what if the only reason I was doing that was to find out what the maximum ListPrice was? Well, instead of using this Order By descending and looking at the top row, I could instead just do something like this. SELECT MAX. Now instead of saying SELECT MAX with the asterisk, saying SELECT MAX of everything, I'm just focused on one particular column. What's the maximum value of ListPrice in the entire Product table? In this case, we'll bring back $699.

16 Aggregate Functions Instead of using this Order By descending and looking at the top row, I could instead just do something like this. SELECT MAX. Now instead of saying SELECT MAX with the asterisk, saying SELECT MAX of everything, I'm just focused on one particular column. What's the maximum value of ListPrice in the entire Product table? In this case, we'll bring back $699.

17 Aggregate Functions If we have MAX for maximum, it's a pretty good guess that we're also going to have MIN for minimum, and we do. We also have AVG for average. We would add up all the values in the ListPrice column divided by the number of rows and return that single value.

18 Aggregate Functions While we've seen COUNT, there's also an option of SUM, which instead of counting the rows will total all the values up. So, in this case with this statement, we're looking for a CustomerID equal to 854 that will find all the rows for that customer and then add together all the values in the total due column.

19 Aggregate Functions And that's one of the great things about working with Aggregate functions that they really don't allow an awful lot of complexity. They are going to return a single number. They need to be very straightforward to customize. However, we can take them one step further. We've seen how we can use the idea of SELECT COUNT (*) to get the number of rows. We can use it in conjunction with a WHERE clause. In this case, COUNT up the number of rows where the color is equal to 'Red', and we'll get some result back.

20 Aggregate Functions But if I wanted to know not just the COUNT of Red Products or All Products, but I want to know how many Red Products we have, how many Black Products we have, Silver, Gold and so on, well, I could create multiple statements like this just changing the WHERE clause every time. But that's not only tedious, it assumes I know ahead of time what all the colors will be, and we might be adding new colors all the time. But if I wanted to know not just the COUNT of Red Products or All Products, but I want to know how many Red Products we have, how many Black Products we have, Silver, Gold and so on. What I can do is add another SQL keyword, which is great for use with the Aggregate functions, and that is GROUP BY. So, I'm selecting here to GROUP BY Color. It will count up all the products for a particular color, because we've told that to group by color. A GROUP BY is something that only makes sense with Aggregate functions. You don't use GROUP BY otherwise. Conversely on the other side, if you are using an Aggregate function, you are pretty much always going to use it by itself unless you used GROUP BY, because the most you would ever expect to return from your query is one single value unless you are using GROUP BY to categorize those results.

21 After a while, you're going to find that very straight forward SQL statements where you're just selecting a few pieces of data from a single table, well, they end up being a little limiting. If we've gone to all the trouble of defining multiple tables to store our data, we do that with the understanding that it will be possible to get it all back using the relationships that we've described. So, I want to have one SQL query not to be limited to selecting from one table but to be able to select from two different tables or even three or more and the phrase we're going to use is to join our tables together.

22 Joining Tables So, in the example I'm going to go through, we have an Employee table and a Department table, and there's a one-to-many relationship between department and employee using the Department ID column.

23 Joining Tables Department ID is a foreign key and employee is a primary key in Department, and it's just so we don't store redundant department details for each employee row. Now the question is how would we start to join these together in SQL?

24 Joining Tables Let's begin just by doing a fairly regular SQL Statement. So, I'm selecting a few columns, First Name, Last Name, Hire Date, and Department ID just from the employee table. So, we've seen this one before. No surprises there in the results that we would expect.

25 Joining Tables To start involving the other table, the magic word here is JOIN. After the Employee table, I'm going to use the word JOIN and then say Department. So, from Employee join Department. This by itself isn't doing very much but we're starting to add the necessary pieces bit by bit. If I say I want to join these two tables together, I can then start adding columns from the Department table to the Select clause. So, after Department ID, I'm going to say common name, location that are both columns in my Department table. But immediately, we have a problem. If I'm now selecting from two different tables, it's really common that it will have a name conflict. In this case, Department ID is going to give us a problem here because Department ID exists as a column in the Employee table, and as a column in the Department table. So, the SQL query would be very confused, which one am I talking about?

26 Joining Tables What I could do is just to prefix that with the name of the table, and it wouldn't actually really matter which one we picked, but we need to be explicit so that SQL doesn't get confused. And if I wanted my SQL statement here to be very explicit, I could do this for every column. So, select employee.first name, employee.lastname, employee.hiredate, department.name, department.location and so on, but I still do have an issue. I still couldn't run this query because I need to describe exactly how these tables are to be joined together. The way that we do that is to use the word ON, and we'll use that in conjunction with JOIN. So, it's Employee JOIN Department ON, and I name the columns in each table and how they link together.

27 Joining Tables If I run that statement, we'll get the results back which are combining, joining these two tables together. Now, one important idea here is in the kind of join that we're doing right now. It's only going to bring back rows where there it is a match between the two tables. So, if you notice in the actual employee table at the top, the third row is Alice Bailey. Well, Alice has a Department ID column value of null. She's not linking to Department. So, what that means is when we do the join, we will not get a row coming back for Alice Bailey because it has to have a match, and that's because what we're doing here is called an inner join. So, I am using this JOIN keyword here, and if I was to be good about this, and I usually would be, I should use the words INNER JOIN rather than JOIN, even though that is the default kind of JOIN is an INNER JOIN.

28 Joining Tables Using an INNER JOIN means only bring back the rows where there is a match in both tables. So, we'll neither see the row like Alice Bailey because she has a Department ID of null but on the other hand nor will we see any of rows from the Department table that don't have matching Employees. In this simple example here, I don't have anybody with the Department ID of one so I'm never seeing the row that says Production CA with the budget code of A4, but sometimes you might want to start involving these other rows that don't exactly match, and that would be by creating something called an OUTER JOIN.

29 Joining Tables An OUTER JOIN means we're going to pick one of the tables and say this one takes precedence. We want to see all of the rows return from a particular table and still show the matching data where possible. Now, that might sound a little weird so let me demonstrate what the difference would be. So instead of using the INNER JOIN keywords, I'm going to use OUTER JOIN, but I can't just write OUTER JOIN I have to be explicit. With an OUTER JOIN, you are typically saying one of these tables takes precedence over the other. We are interested in where they match but we still want to get the results where they don't. So, I would typically use the word left or right, A LEFT OUTER JOIN or a RIGHT OUTER JOIN. The left and right here simply means is that the table on the left-hand side of the word JOIN, which for us as employee, or it is the one on the right-hand side of the word join, which will be department. So, in this one, I'm going to do a LEFT OUTER JOIN, and it's going to look to the left to the word join and see employee and then say that employee will take precedence.

30 Joining Tables

31 BIT 275 ICE 03 31

Instructor: Craig Duckett. Lecture 04: Thursday, April 5, Relationships

Instructor: Craig Duckett. Lecture 04: Thursday, April 5, Relationships Instructor: Craig Duckett Lecture 04: Thursday, April 5, 2018 Relationships 1 Assignment 1 is due NEXT LECTURE 5, Tuesday, April 10 th in StudentTracker by MIDNIGHT MID-TERM EXAM is LECTURE 10, Tuesday,

More information

Instructor: Craig Duckett. Lecture 07: Tuesday, April 17 th, 2018 Conflicts and Isolation, MySQL Workbench

Instructor: Craig Duckett. Lecture 07: Tuesday, April 17 th, 2018 Conflicts and Isolation, MySQL Workbench Instructor: Craig Duckett Lecture 07: Tuesday, April 17 th, 2018 Conflicts and Isolation, MySQL Workbench 1 MID-TERM EXAM is LECTURE 10, Tuesday, May 1st Assignment 2 is due LECTURE 12, Tuesday, May 8

More information

Instructor: Craig Duckett. Lecture 02: Thursday, March 29 th, 2018 SQL Basics and SELECT, FROM, WHERE

Instructor: Craig Duckett. Lecture 02: Thursday, March 29 th, 2018 SQL Basics and SELECT, FROM, WHERE Instructor: Craig Duckett Lecture 02: Thursday, March 29 th, 2018 SQL Basics and SELECT, FROM, WHERE 1 Assignment 1 is due LECTURE 5, Tuesday, April 10 th, 2018 in StudentTracker by MIDNIGHT MID-TERM EXAM

More information

Assignment 1 DUE TONIGHT

Assignment 1 DUE TONIGHT Instructor: Craig Duckett Assignment 1 DUE TONIGHT Lecture 05: Tuesday, April 10 th, 2018 Transactions, Acid Test, DML, DDL 1 Assignment 1 is due TONIGHT LECTURE 5, Tuesday, April 10 th in StudentTracker

More information

The Stack, Free Store, and Global Namespace

The Stack, Free Store, and Global Namespace Pointers This tutorial is my attempt at clarifying pointers for anyone still confused about them. Pointers are notoriously hard to grasp, so I thought I'd take a shot at explaining them. The more information

More information

CSE 530A SQL. Washington University Fall 2013

CSE 530A SQL. Washington University Fall 2013 CSE 530A SQL Washington University Fall 2013 SELECT SELECT * FROM employee; employee_id last_name first_name department salary -------------+-----------+------------+-----------------+-------- 12345 Bunny

More information

Data Manipulation Language (DML)

Data Manipulation Language (DML) In the name of Allah Islamic University of Gaza Faculty of Engineering Computer Engineering Department ECOM 4113 DataBase Lab Lab # 3 Data Manipulation Language (DML) El-masry 2013 Objective To be familiar

More information

Formal Methods of Software Design, Eric Hehner, segment 24 page 1 out of 5

Formal Methods of Software Design, Eric Hehner, segment 24 page 1 out of 5 Formal Methods of Software Design, Eric Hehner, segment 24 page 1 out of 5 [talking head] This lecture we study theory design and implementation. Programmers have two roles to play here. In one role, they

More information

MITOCW ocw f99-lec07_300k

MITOCW ocw f99-lec07_300k MITOCW ocw-18.06-f99-lec07_300k OK, here's linear algebra lecture seven. I've been talking about vector spaces and specially the null space of a matrix and the column space of a matrix. What's in those

More information

MITOCW watch?v=0jljzrnhwoi

MITOCW watch?v=0jljzrnhwoi MITOCW watch?v=0jljzrnhwoi The following content is provided under a Creative Commons license. Your support will help MIT OpenCourseWare continue to offer high quality educational resources for free. To

More information

Instructor: Craig Duckett. Lecture 11: Thursday, May 3 th, Set Operations, Subqueries, Views

Instructor: Craig Duckett. Lecture 11: Thursday, May 3 th, Set Operations, Subqueries, Views Instructor: Craig Duckett Lecture 11: Thursday, May 3 th, 2018 Set Operations, Subqueries, Views 1 MID-TERM EXAM GRADED! Assignment 2 is due LECTURE 12, NEXT Tuesday, May 8 th in StudentTracker by MIDNIGHT

More information

Advance Database Systems. Joining Concepts in Advanced SQL Lecture# 4

Advance Database Systems. Joining Concepts in Advanced SQL Lecture# 4 Advance Database Systems Joining Concepts in Advanced SQL Lecture# 4 Lecture 4: Joining Concepts in Advanced SQL Join Cross Join Inner Join Outer Join 3 Join 4 Join A SQL join clause combines records from

More information

In our first lecture on sets and set theory, we introduced a bunch of new symbols and terminology.

In our first lecture on sets and set theory, we introduced a bunch of new symbols and terminology. Guide to and Hi everybody! In our first lecture on sets and set theory, we introduced a bunch of new symbols and terminology. This guide focuses on two of those symbols: and. These symbols represent concepts

More information

How to Improve Your Campaign Conversion Rates

How to Improve Your  Campaign Conversion Rates How to Improve Your Email Campaign Conversion Rates Chris Williams Author of 7 Figure Business Models How to Exponentially Increase Conversion Rates I'm going to teach you my system for optimizing an email

More information

MITOCW watch?v=rvrkt-jxvko

MITOCW watch?v=rvrkt-jxvko MITOCW watch?v=rvrkt-jxvko The following content is provided under a Creative Commons license. Your support will help MIT OpenCourseWare continue to offer high quality educational resources for free. To

More information

Introduction to Databases and SQL

Introduction to Databases and SQL Introduction to Databases and SQL Files vs Databases In the last chapter you learned how your PHP scripts can use external files to store and retrieve data. Although files do a great job in many circumstances,

More information

The following content is provided under a Creative Commons license. Your support

The following content is provided under a Creative Commons license. Your support MITOCW Lecture 9 The following content is provided under a Creative Commons license. Your support will help MIT OpenCourseWare continue to offer high-quality educational resources for free. To make a donation

More information

CSC Web Programming. Introduction to SQL

CSC Web Programming. Introduction to SQL CSC 242 - Web Programming Introduction to SQL SQL Statements Data Definition Language CREATE ALTER DROP Data Manipulation Language INSERT UPDATE DELETE Data Query Language SELECT SQL statements end with

More information

Instructor: Craig Duckett. Lecture 14: Tuesday, May 15 th, 2018 Stored Procedures (SQL Server) and MySQL

Instructor: Craig Duckett. Lecture 14: Tuesday, May 15 th, 2018 Stored Procedures (SQL Server) and MySQL Instructor: Craig Duckett Lecture 14: Tuesday, May 15 th, 2018 Stored Procedures (SQL Server) and MySQL 1 Assignment 3 is due LECTURE 20, Tuesday, June 5 th Database Presentation is due LECTURE 20, Tuesday,

More information

Linked Lists. What is a Linked List?

Linked Lists. What is a Linked List? Linked Lists Along with arrays, linked lists form the basis for pretty much every other data stucture out there. This makes learning and understand linked lists very important. They are also usually the

More information

Lesson 3 Transcript: Part 1 of 2 - Tools & Scripting

Lesson 3 Transcript: Part 1 of 2 - Tools & Scripting Lesson 3 Transcript: Part 1 of 2 - Tools & Scripting Slide 1: Cover Welcome to lesson 3 of the db2 on Campus lecture series. Today we're going to talk about tools and scripting, and this is part 1 of 2

More information

MITOCW watch?v=yarwp7tntl4

MITOCW watch?v=yarwp7tntl4 MITOCW watch?v=yarwp7tntl4 The following content is provided under a Creative Commons license. Your support will help MIT OpenCourseWare continue to offer high quality, educational resources for free.

More information

PROFESSOR: Well, yesterday we learned a bit about symbolic manipulation, and we wrote a rather stylized

PROFESSOR: Well, yesterday we learned a bit about symbolic manipulation, and we wrote a rather stylized MITOCW Lecture 4A PROFESSOR: Well, yesterday we learned a bit about symbolic manipulation, and we wrote a rather stylized program to implement a pile of calculus rule from the calculus book. Here on the

More information

MITOCW watch?v=zm5mw5nkzjg

MITOCW watch?v=zm5mw5nkzjg MITOCW watch?v=zm5mw5nkzjg The following content is provided under a Creative Commons license. Your support will help MIT OpenCourseWare continue to offer high quality educational resources for free. To

More information

Querying Data with Transact SQL

Querying Data with Transact SQL Course 20761A: Querying Data with Transact SQL Course details Course Outline Module 1: Introduction to Microsoft SQL Server 2016 This module introduces SQL Server, the versions of SQL Server, including

More information

6.830 Lecture PS1 Due Next Time (Tuesday!) Lab 1 Out end of week start early!

6.830 Lecture PS1 Due Next Time (Tuesday!) Lab 1 Out end of week start early! 6.830 Lecture 3 9.13.2017 PS1 Due Next Time (Tuesday!) Lab 1 Out end of week start early! Relational Model Continued, and Schema Design and Normalization Animals(name,age,species,cageno,keptby,feedtime)

More information

It Might Be Valid, But It's Still Wrong Paul Maskens and Andy Kramek

It Might Be Valid, But It's Still Wrong Paul Maskens and Andy Kramek Seite 1 von 5 Issue Date: FoxTalk July 2000 It Might Be Valid, But It's Still Wrong Paul Maskens and Andy Kramek This month, Paul Maskens and Andy Kramek discuss the problems of validating data entry.

More information

Introductory SQL SQL Joins: Viewing Relationships Pg 1

Introductory SQL SQL Joins: Viewing Relationships Pg 1 Introductory SQL SQL Joins: Viewing Relationships Pg 1 SQL Joins: Viewing Relationships Ray Lockwood Points: The relational model uses foreign keys to establish relationships between tables. SQL uses Joins

More information

Advanced SQL GROUP BY Clause and Aggregate Functions Pg 1

Advanced SQL GROUP BY Clause and Aggregate Functions Pg 1 Advanced SQL Clause and Functions Pg 1 Clause and Functions Ray Lockwood Points: s (such as COUNT( ) work on groups of Instead of returning every row read from a table, we can aggregate rows together using

More information

MITOCW ocw f99-lec12_300k

MITOCW ocw f99-lec12_300k MITOCW ocw-18.06-f99-lec12_300k This is lecture twelve. OK. We've reached twelve lectures. And this one is more than the others about applications of linear algebra. And I'll confess. When I'm giving you

More information

MITOCW watch?v=flgjisf3l78

MITOCW watch?v=flgjisf3l78 MITOCW watch?v=flgjisf3l78 The following content is provided under a Creative Commons license. Your support will help MIT OpenCourseWare continue to offer high-quality educational resources for free. To

More information

Based on the following Table(s), Write down the queries as indicated: 1. Write an SQL query to insert a new row in table Dept with values: 4, Prog, MO

Based on the following Table(s), Write down the queries as indicated: 1. Write an SQL query to insert a new row in table Dept with values: 4, Prog, MO Based on the following Table(s), Write down the queries as indicated: 1. Write an SQL query to insert a new row in table Dept with values: 4, Prog, MO INSERT INTO DEPT VALUES(4, 'Prog','MO'); The result

More information

Carnegie Mellon Univ. Dept. of Computer Science /615 - DB Applications. Administrivia. Administrivia. Faloutsos/Pavlo CMU /615

Carnegie Mellon Univ. Dept. of Computer Science /615 - DB Applications. Administrivia. Administrivia. Faloutsos/Pavlo CMU /615 Carnegie Mellon Univ. Dept. of Computer Science 15-415/615 - DB Applications C. Faloutsos A. Pavlo Lecture#14(b): Implementation of Relational Operations Administrivia HW4 is due today. HW5 is out. Faloutsos/Pavlo

More information

P1_L3 Operating Systems Security Page 1

P1_L3 Operating Systems Security Page 1 P1_L3 Operating Systems Security Page 1 that is done by the operating system. systems. The operating system plays a really critical role in protecting resources in a computer system. Resources such as

More information

MANAGING DATA(BASES) USING SQL (NON-PROCEDURAL SQL, X401.9)

MANAGING DATA(BASES) USING SQL (NON-PROCEDURAL SQL, X401.9) Technology & Information Management Instructor: Michael Kremer, Ph.D. Class 6 Professional Program: Data Administration and Management MANAGING DATA(BASES) USING SQL (NON-PROCEDURAL SQL, X401.9) AGENDA

More information

MITOCW watch?v=4dj1oguwtem

MITOCW watch?v=4dj1oguwtem MITOCW watch?v=4dj1oguwtem PROFESSOR: So it's time to examine uncountable sets. And that's what we're going to do in this segment. So Cantor's question was, are all sets the same size? And he gives a definitive

More information

Slide 1 CS 170 Java Programming 1 Testing Karel

Slide 1 CS 170 Java Programming 1 Testing Karel CS 170 Java Programming 1 Testing Karel Introducing Unit Tests to Karel's World Slide 1 CS 170 Java Programming 1 Testing Karel Hi Everybody. This is the CS 170, Java Programming 1 lecture, Testing Karel.

More information

Using Parameter Queries

Using Parameter Queries [Revised and Updated 21 August 2018] A useful feature of the query is that it can be saved and used again and again, whenever we want to ask the same question. The result we see (the recordset) always

More information

Oracle Database 11g: SQL and PL/SQL Fundamentals

Oracle Database 11g: SQL and PL/SQL Fundamentals Oracle University Contact Us: +33 (0) 1 57 60 20 81 Oracle Database 11g: SQL and PL/SQL Fundamentals Duration: 5 Days What you will learn In this course, students learn the fundamentals of SQL and PL/SQL

More information

1 of 10 5/11/2006 12:10 AM CS 61A Spring 2006 Midterm 3 solutions 1. Box and pointer. > (let ((x (list 1 2 3))) (set-car! (cdr x) (cddr x)) x) (1 (3) 3) +-------------+ V --------- -- ------ ---------

More information

The following content is provided under a Creative Commons license. Your support

The following content is provided under a Creative Commons license. Your support MITOCW Lecture 11 The following content is provided under a Creative Commons license. Your support will help MIT OpenCourseWare continue to offer high quality educational resources for free. To make a

More information

In This Lecture. Yet More SQL SELECT ORDER BY. SQL SELECT Overview. ORDER BY Example. ORDER BY Example. Yet more SQL

In This Lecture. Yet More SQL SELECT ORDER BY. SQL SELECT Overview. ORDER BY Example. ORDER BY Example. Yet more SQL In This Lecture Yet More SQL Database Systems Lecture 9 Natasha Alechina Yet more SQL ORDER BY Aggregate functions and HAVING etc. For more information Connoly and Begg Chapter 5 Ullman and Widom Chapter

More information

MITOCW watch?v=kz7jjltq9r4

MITOCW watch?v=kz7jjltq9r4 MITOCW watch?v=kz7jjltq9r4 PROFESSOR: We're going to look at the most fundamental of all mathematical data types, namely sets, and let's begin with the definitions. So informally, a set is a collection

More information

PROFESSOR: Well, now that we've given you some power to make independent local state and to model objects,

PROFESSOR: Well, now that we've given you some power to make independent local state and to model objects, MITOCW Lecture 5B PROFESSOR: Well, now that we've given you some power to make independent local state and to model objects, I thought we'd do a bit of programming of a very complicated kind, just to illustrate

More information

PROFESSOR: Last time, we took a look at an explicit control evaluator for Lisp, and that bridged the gap between

PROFESSOR: Last time, we took a look at an explicit control evaluator for Lisp, and that bridged the gap between MITOCW Lecture 10A [MUSIC PLAYING] PROFESSOR: Last time, we took a look at an explicit control evaluator for Lisp, and that bridged the gap between all these high-level languages like Lisp and the query

More information

MySQL Workshop. Scott D. Anderson

MySQL Workshop. Scott D. Anderson MySQL Workshop Scott D. Anderson Workshop Plan Part 1: Simple Queries Part 2: Creating a database Part 3: Joining tables Part 4: complex queries: grouping aggregate functions subqueries sorting Reference:

More information

Lesson 14 Transcript: Triggers

Lesson 14 Transcript: Triggers Lesson 14 Transcript: Triggers Slide 1: Cover Welcome to Lesson 14 of DB2 on Campus Lecture Series. Today, we are going to talk about Triggers. My name is Raul Chong, and I'm the DB2 on Campus Program

More information

Post Experiment Interview Questions

Post Experiment Interview Questions Post Experiment Interview Questions Questions about the Maximum Problem 1. What is this problem statement asking? 2. What is meant by positive integers? 3. What does it mean by the user entering valid

More information

Well, Hal just told us how you build robust systems. The key idea was-- I'm sure that many of

Well, Hal just told us how you build robust systems. The key idea was-- I'm sure that many of MITOCW Lecture 3B [MUSIC PLAYING] Well, Hal just told us how you build robust systems. The key idea was-- I'm sure that many of you don't really assimilate that yet-- but the key idea is that in order

More information

You can write a command to retrieve specified columns and all rows from a table, as illustrated

You can write a command to retrieve specified columns and all rows from a table, as illustrated CHAPTER 4 S I N G L E - TA BL E QUERIES LEARNING OBJECTIVES Objectives Retrieve data from a database using SQL commands Use simple and compound conditions in queries Use the BETWEEN, LIKE, and IN operators

More information

MITOCW MIT6_01SC_rec2_300k.mp4

MITOCW MIT6_01SC_rec2_300k.mp4 MITOCW MIT6_01SC_rec2_300k.mp4 KENDRA PUGH: Hi. I'd like to talk to you today about inheritance as a fundamental concept in object oriented programming, its use in Python, and also tips and tricks for

More information

mk-convert Contents 1 Converting to minikanren, quasimatically. 08 July 2014

mk-convert Contents 1 Converting to minikanren, quasimatically. 08 July 2014 mk-convert 08 July 2014 Contents 1 Converting to minikanren, quasimatically. 1 1.1 Variations on a Scheme..................... 2 1.2 Racket to minikanren, nally.................. 8 1.3 Back to the beginning......................

More information

INTERMEDIATE SQL GOING BEYOND THE SELECT. Created by Brian Duffey

INTERMEDIATE SQL GOING BEYOND THE SELECT. Created by Brian Duffey INTERMEDIATE SQL GOING BEYOND THE SELECT Created by Brian Duffey WHO I AM Brian Duffey 3 years consultant at michaels, ross, and cole 9+ years SQL user What have I used SQL for? ROADMAP Introduction 1.

More information

Intermediate SQL: Aggregated Data, Joins and Set Operators

Intermediate SQL: Aggregated Data, Joins and Set Operators Intermediate SQL: Aggregated Data, Joins and Set Operators Aggregated Data and Sorting Objectives After completing this lesson, you should be able to do the following: Identify the available group functions

More information

Introduction to SQL Server 2005/2008 and Transact SQL

Introduction to SQL Server 2005/2008 and Transact SQL Introduction to SQL Server 2005/2008 and Transact SQL Week 2 TRANSACT SQL CRUD Create, Read, Update, and Delete Steve Stedman - Instructor Steve@SteveStedman.com Homework Review Review of homework from

More information

30. Structured Query Language (SQL)

30. Structured Query Language (SQL) 30. Structured Query Language (SQL) Java Fall 2009 Instructor: Dr. Masoud Yaghini Outline SQL query keywords Basic SELECT Query WHERE Clause ORDER BY Clause INNER JOIN Clause INSERT Statement UPDATE Statement

More information

Querying Data with Transact-SQL

Querying Data with Transact-SQL Course 20761A: Querying Data with Transact-SQL Page 1 of 5 Querying Data with Transact-SQL Course 20761A: 2 days; Instructor-Led Introduction The main purpose of this 2 day instructor led course is to

More information

MITOCW watch?v=w_-sx4vr53m

MITOCW watch?v=w_-sx4vr53m MITOCW watch?v=w_-sx4vr53m The following content is provided under a Creative Commons license. Your support will help MIT OpenCourseWare continue to offer high-quality educational resources for free. To

More information

PROFESSOR: So far in this course we've been talking a lot about data abstraction. And remember the idea is that

PROFESSOR: So far in this course we've been talking a lot about data abstraction. And remember the idea is that MITOCW Lecture 4B [MUSIC-- "JESU, JOY OF MAN'S DESIRING" BY JOHANN SEBASTIAN BACH] PROFESSOR: So far in this course we've been talking a lot about data abstraction. And remember the idea is that we build

More information

SQL Data Query Language

SQL Data Query Language SQL Data Query Language André Restivo 1 / 68 Index Introduction Selecting Data Choosing Columns Filtering Rows Set Operators Joining Tables Aggregating Data Sorting Rows Limiting Data Text Operators Nested

More information

Oracle Database: SQL and PL/SQL Fundamentals NEW

Oracle Database: SQL and PL/SQL Fundamentals NEW Oracle Database: SQL and PL/SQL Fundamentals NEW Duration: 5 Days What you will learn This Oracle Database: SQL and PL/SQL Fundamentals training delivers the fundamentals of SQL and PL/SQL along with the

More information

Autodesk University Step Up Your Game AutoCAD P&ID and SQL: Making Data Work for You Skill Level: All Levels

Autodesk University Step Up Your Game AutoCAD P&ID and SQL: Making Data Work for You Skill Level: All Levels Autodesk University Step Up Your Game AutoCAD P&ID and SQL: Making Data Work for You Skill Level: All Levels JULIAN CHAVEZ: Good afternoon, ladies and gentlemen. Last class of the last day and everybody's

More information

Simple queries Set operations Aggregate operators Null values Joins Query Optimization. John Edgar 2

Simple queries Set operations Aggregate operators Null values Joins Query Optimization. John Edgar 2 CMPT 354 Simple queries Set operations Aggregate operators Null values Joins Query Optimization John Edgar 2 Data Manipulation Language (DML) to Write queries Insert, delete and modify records Data Definition

More information

The following content is provided under a Creative Commons license. Your support

The following content is provided under a Creative Commons license. Your support MITOCW Lecture 10 The following content is provided under a Creative Commons license. Your support will help MIT OpenCourseWare continue to offer high-quality educational resources for free. To make a

More information

Instructor (Julie Zelenski)

Instructor (Julie Zelenski) ProgrammingAbstractions-Lecture22 Instructor (Julie Zelenski):How are we doing? Spring apparently is here; just like California, one day it's winter, one day it's spring. Hopefully it's here to say. Hopefully

More information

MITOCW watch?v=9h6muyzjms0

MITOCW watch?v=9h6muyzjms0 MITOCW watch?v=9h6muyzjms0 The following content is provided under a Creative Commons license. Your support will help MIT OpenCourseWare continue to offer high quality educational resources for free. To

More information

Relational Database Development

Relational Database Development Instructor s Relational Database Development Views, Indexes & Security Relational Database Development 152-156 Views, Indexes & Security Quick Links & Text References View Description Pages 182 183 187

More information

MITOCW watch?v=se4p7ivcune

MITOCW watch?v=se4p7ivcune MITOCW watch?v=se4p7ivcune The following content is provided under a Creative Commons license. Your support will help MIT OpenCourseWare continue to offer high quality educational resources for free. To

More information

Creating a Database Using Access 2003 for Windows 2000/Me/2003

Creating a Database Using Access 2003 for Windows 2000/Me/2003 Creating a Database Using Access 2003 for Windows 2000/Me/2003 Created: 25 September 2003 Starting Access 2003 Double click on the Access 2003 icon on the Windows desktop (see right), or click-on the Start

More information

Oracle Database: SQL and PL/SQL Fundamentals Ed 2

Oracle Database: SQL and PL/SQL Fundamentals Ed 2 Oracle University Contact Us: Local: 1800 103 4775 Intl: +91 80 67863102 Oracle Database: SQL and PL/SQL Fundamentals Ed 2 Duration: 5 Days What you will learn This Oracle Database: SQL and PL/SQL Fundamentals

More information

Microsoft Access 2007 Tutorial. Creating a Database using Access 2007

Microsoft Access 2007 Tutorial. Creating a Database using Access 2007 Creating a Database using Access 2007 Created: 12 December 2006 Starting Access 2007 Double click on the Access 2007 icon on the Windows desktop (see right), or click-on the Start button in the lower left

More information

The following content is provided under a Creative Commons license. Your support

The following content is provided under a Creative Commons license. Your support MITOCW Lecture 2 The following content is provided under a Creative Commons license. Your support will help MIT OpenCourseWare continue to offer high quality educational resources for free. To make a donation

More information

Hi everyone. I hope everyone had a good Fourth of July. Today we're going to be covering graph search. Now, whenever we bring up graph algorithms, we

Hi everyone. I hope everyone had a good Fourth of July. Today we're going to be covering graph search. Now, whenever we bring up graph algorithms, we Hi everyone. I hope everyone had a good Fourth of July. Today we're going to be covering graph search. Now, whenever we bring up graph algorithms, we have to talk about the way in which we represent the

More information

Full file at

Full file at David Kroenke's Database Processing: Fundamentals, Design and Implementation (10 th Edition) CHAPTER TWO INTRODUCTION TO STRUCTURED QUERY LANGUAGE (SQL) True-False Questions 1. SQL stands for Standard

More information

SQL CHEAT SHEET. created by Tomi Mester

SQL CHEAT SHEET. created by Tomi Mester SQL CHEAT SHEET created by Tomi Mester I originally created this cheat sheet for my SQL course and workshop participants.* But I have decided to open-source it and make it available for everyone who wants

More information

3/3/2008. Announcements. A Table with a View (continued) Fields (Attributes) and Primary Keys. Video. Keys Primary & Foreign Primary/Foreign Key

3/3/2008. Announcements. A Table with a View (continued) Fields (Attributes) and Primary Keys. Video. Keys Primary & Foreign Primary/Foreign Key Announcements Quiz will cover chapter 16 in Fluency Nothing in QuickStart Read Chapter 17 for Wednesday Project 3 3A due Friday before 11pm 3B due Monday, March 17 before 11pm A Table with a View (continued)

More information

MITOCW watch?v=penh4mv5gag

MITOCW watch?v=penh4mv5gag MITOCW watch?v=penh4mv5gag PROFESSOR: Graph coloring is the abstract version of a problem that arises from a bunch of conflict scheduling situations. So let's look at an example first and then define the

More information

The following content is provided under a Creative Commons license. Your support

The following content is provided under a Creative Commons license. Your support MITOCW Lecture 8 The following content is provided under a Creative Commons license. Your support will help MIT OpenCourseWare continue to offer high quality educational resources for free. To make a donation

More information

BEGINNER PHP Table of Contents

BEGINNER PHP Table of Contents Table of Contents 4 5 6 7 8 9 0 Introduction Getting Setup Your first PHP webpage Working with text Talking to the user Comparison & If statements If & Else Cleaning up the game Remembering values Finishing

More information

Querying Data with Transact SQL Microsoft Official Curriculum (MOC 20761)

Querying Data with Transact SQL Microsoft Official Curriculum (MOC 20761) Querying Data with Transact SQL Microsoft Official Curriculum (MOC 20761) Course Length: 3 days Course Delivery: Traditional Classroom Online Live MOC on Demand Course Overview The main purpose of this

More information

T-SQL Training: T-SQL for SQL Server for Developers

T-SQL Training: T-SQL for SQL Server for Developers Duration: 3 days T-SQL Training Overview T-SQL for SQL Server for Developers training teaches developers all the Transact-SQL skills they need to develop queries and views, and manipulate data in a SQL

More information

Institute of Aga. Microsoft SQL Server LECTURER NIYAZ M. SALIH

Institute of Aga. Microsoft SQL Server LECTURER NIYAZ M. SALIH Institute of Aga 2018 Microsoft SQL Server LECTURER NIYAZ M. SALIH Database: A Database is a collection of related data organized in a way that data can be easily accessed, managed and updated. Any piece

More information

(Refer Slide Time: 00:50)

(Refer Slide Time: 00:50) Programming, Data Structures and Algorithms Prof. N.S. Narayanaswamy Department of Computer Science and Engineering Indian Institute of Technology Madras Module - 03 Lecture 30 Searching Unordered linear

More information

NESTED QUERIES AND AGGREGATION CHAPTER 5 (6/E) CHAPTER 8 (5/E)

NESTED QUERIES AND AGGREGATION CHAPTER 5 (6/E) CHAPTER 8 (5/E) 1 NESTED QUERIES AND AGGREGATION CHAPTER 5 (6/E) CHAPTER 8 (5/E) 2 LECTURE OUTLINE More Complex SQL Retrieval Queries Self-Joins Renaming Attributes and Results Grouping, Aggregation, and Group Filtering

More information

INDEX. 1 Basic SQL Statements. 2 Restricting and Sorting Data. 3 Single Row Functions. 4 Displaying data from multiple tables

INDEX. 1 Basic SQL Statements. 2 Restricting and Sorting Data. 3 Single Row Functions. 4 Displaying data from multiple tables INDEX Exercise No Title 1 Basic SQL Statements 2 Restricting and Sorting Data 3 Single Row Functions 4 Displaying data from multiple tables 5 Creating and Managing Tables 6 Including Constraints 7 Manipulating

More information

MITOCW watch?v=hverxup4cfg

MITOCW watch?v=hverxup4cfg MITOCW watch?v=hverxup4cfg PROFESSOR: We've briefly looked at graph isomorphism in the context of digraphs. And it comes up in even more fundamental way really for simple graphs where the definition is

More information

MIS2502: Data Analytics SQL Getting Information Out of a Database Part 1: Basic Queries

MIS2502: Data Analytics SQL Getting Information Out of a Database Part 1: Basic Queries MIS2502: Data Analytics SQL Getting Information Out of a Database Part 1: Basic Queries JaeHwuen Jung jaejung@temple.edu http://community.mis.temple.edu/jaejung Where we are Now we re here Data entry Transactional

More information

Database Systems: Design, Implementation, and Management Tenth Edition. Chapter 7 Introduction to Structured Query Language (SQL)

Database Systems: Design, Implementation, and Management Tenth Edition. Chapter 7 Introduction to Structured Query Language (SQL) Database Systems: Design, Implementation, and Management Tenth Edition Chapter 7 Introduction to Structured Query Language (SQL) Objectives In this chapter, students will learn: The basic commands and

More information

Skill 1: Multiplying Polynomials

Skill 1: Multiplying Polynomials CS103 Spring 2018 Mathematical Prerequisites Although CS103 is primarily a math class, this course does not require any higher math as a prerequisite. The most advanced level of mathematics you'll need

More information

Module 2.3a IP 0:00 - 1:00 -

Module 2.3a IP 0:00 - 1:00 - Module 2.3a IP 0:00 - In this video we're going to continue looking at our simplified view of how the internet layers work and in particular we're going to look at the middle layer which is good known

More information

(Refer Slide Time: 00:51)

(Refer Slide Time: 00:51) Programming, Data Structures and Algorithms Prof. Shankar Balachandran Department of Computer Science and Engineering Indian Institute Technology, Madras Module 10 E Lecture 24 Content Example: factorial

More information

Blitz2D Newbies: Definitive Guide to Types by MutteringGoblin

Blitz2D Newbies: Definitive Guide to Types by MutteringGoblin Blitz2D Newbies: Definitive Guide to Types by MutteringGoblin Types are probably the hardest thing to understand about Blitz Basic. If you're using types for the first time, you've probably got an uneasy

More information

Jarek Szlichta

Jarek Szlichta Jarek Szlichta http://data.science.uoit.ca/ SQL is a standard language for accessing and manipulating databases What is SQL? SQL stands for Structured Query Language SQL lets you gain access and control

More information

Definition: A data structure is a way of organizing data in a computer so that it can be used efficiently.

Definition: A data structure is a way of organizing data in a computer so that it can be used efficiently. The Science of Computing I Lesson 4: Introduction to Data Structures Living with Cyber Pillar: Data Structures The need for data structures The algorithms we design to solve problems rarely do so without

More information

Troubleshooting Maple Worksheets: Common Problems

Troubleshooting Maple Worksheets: Common Problems Troubleshooting Maple Worksheets: Common Problems So you've seen plenty of worksheets that work just fine, but that doesn't always help you much when your worksheet isn't doing what you want it to. This

More information

Relational Database Management Systems for Epidemiologists: SQL Part II

Relational Database Management Systems for Epidemiologists: SQL Part II Relational Database Management Systems for Epidemiologists: SQL Part II Outline Summarizing and Grouping Data Retrieving Data from Multiple Tables using JOINS Summary of Aggregate Functions Function MIN

More information

MITOCW watch?v=sdw8_0rdzuw

MITOCW watch?v=sdw8_0rdzuw MITOCW watch?v=sdw8_0rdzuw PROFESSOR: Directed acyclic graphs are a special class of graphs that really have and warrant a theory of their own. Of course, "directed acyclic graphs" is lot of syllables,

More information

6.001 Notes: Section 15.1

6.001 Notes: Section 15.1 6.001 Notes: Section 15.1 Slide 15.1.1 Our goal over the next few lectures is to build an interpreter, which in a very basic sense is the ultimate in programming, since doing so will allow us to define

More information

AHHHHHHH!!!! NOT TESTING! Anything but testing! Beat me, whip me, send me to Detroit, but don t make me write tests!

AHHHHHHH!!!! NOT TESTING! Anything but testing! Beat me, whip me, send me to Detroit, but don t make me write tests! NAME DESCRIPTION Test::Tutorial - A tutorial about writing really basic tests AHHHHHHH!!!! NOT TESTING! Anything but testing! Beat me, whip me, send me to Detroit, but don t make me write tests! *sob*

More information

Azon Master Class. By Ryan Stevenson Guidebook #9 Amazon Advertising

Azon Master Class. By Ryan Stevenson   Guidebook #9 Amazon Advertising Azon Master Class By Ryan Stevenson https://ryanstevensonplugins.com/ Guidebook #9 Amazon Advertising Table of Contents 1. Joining Amazon Associates Program 2. Product Style Joining Amazon Associates Program

More information