CS2 Current Technologies Note 2 CS2Bh
|
|
- Thomas Garrison
- 7 years ago
- Views:
Transcription
1 CS2 Current Technologies Note 2 SQL Programming Basics Introduction We previously introduced the SQL programming language for relational database systems. We will now begin to examine some of SQL s more advanced features. We will primarily restrict ourselves to that part of SQL known as the data manipulation language (DML). The DML addresses the extraction of data from existing tables and their editing (i.e., the updating of table attribute values and adding/deleting of table rows/columns. SQL s data definition language (DDL) supports the definition of the logical and physical structure of databases. The DDL will be explained in detail in CS3. Testing for Multiple Conditions The WHERE clause described above allows us to test for one condition only. This is often not enough. Let s say we want to know the names of all clerks in department 20. To find out who they are, we have to use a WHERE clause that tests for two conditions: whether DEPTNO is equal 20, and whether JOB is equal to CLERK. SQL allows us to specify multiple conditions in the WHERE clause, using the AND connector. The general format of a WHERE clause with multiple conditions is as follows. WHERE condition 1 AND condition 2 AND AND condition n We illustrate this in Example 1, Example 1 List names of all CLERKs who work in department 20 SELECT ENAME FROM EMP WHERE DEPTNO = 20 AND JOB = CLERK ; ENAME SMITH ADAMS 1
2 Testing for Alternative Conditions When using the AND connector, a row is retrieved if it satisfies all conditions connected by AND. Many times, however, we are interested in rows if they satisfy at least one of a number of conditions, but not necessarily all. For example, we would like to know the names of all analysts and managers in the company. To retrieve information of this kind, SQL provides us with the OR connector in the WHERE clause. Its general form looks as follows. WHERE condition 1 OR condition 2 OR OR condition n Example 2 illustrates the use of this construct. Example 2 List the names of all managers and analysts. SELECT ENAME FROM EMP WHERE JOB = MANAGER OR JOB = ANALYST ; ENAME JONES BLAKE CLARK SCOTT FORD Testing for Values in a List Special cases of alternative search conditions are WHERE clauses which test for several values of one column, e.g. the query in Figure 2. Instead of writing a number of equality tests connected by OR, we can use the IN operator. The general form of a WHERE clause using IN is as follows. WHERE column-name IN ( list of values ) We can now rewrite the query in Figure 2 using the IN operator. query is given in Example 3. The new Example 3 List the names of all managers and analysts. SELECT ENAME FROM EMP WHERE JOB IN ( MANAGER, ANALYST ); (The output is the same as the table in Example 2.) 2
3 Testing for Negative Conditions Yet another form of the WHERE clause allows us to retrieve all those rows of a table which do NOT satisfy search conditions in the clause. To do so, we simply use!= instead of =. This construct is illustrated in Example 4. If executed, this query tells us that no records were found, which is to be expected since all analysts work in Department 20. Example 4 List names of analysts who are not working in department 20. SELECT ENAME FROM EMP WHERE JOB = ANALYST AND DEPTNO!= 20; NOTE: Instead of!= we can also use <> or ˆ=. Testing For A Range In all previous examples we used the WHERE clause to test for particular column values. SQL allows us, alternatively, to use search conditions which specify certain ranges of values. The four comparison operators used for range queries are: > for greater than, >= for greater than or equal to, < for less than, and <= for less than or equal to. The query in Example 5 illustrates the use of a comparison operator. Example 5 List employees with salaries higher than SELECT ENAME FROM EMP WHERE SAL > 2500; ENAME JONES BLAKE SCOTT KING FORD If a range query specifies an upper and a lower value for a column, we can use the BETWEEN operator instead of two conditions with comparison operators. The general form of the WHERE clause using the BETWEEN operator is as follows. WHERE column-name BETWEEN lower value AND upper value Example 6 illustrates the use of this construct. Looking at the output from this query, we find that only salespeople and clerks have salaries that fall in this range. We also note that there are many duplicates in the output. In general we are not interested in such duplicates and SQL allows us to suppress them using the DISTINCT keyword in the SELECT clause. 3
4 Example 6 Which jobs are paid less than 2000 but more than 1000? SELECT JOB FROM EMP WHERE SAL BETWEEN 1000 AND 2000; JOB SALESMAN SALESMAN SALESMAN SALESMAN CLERK CLERK Arithmetic Expressions Besides selecting certain columns and rows, SQL provides a number of functions which allow us to create new information based on existing tables. Given table EMP we know the salary and the commission of each salesman, but the total income is not explicitly stated. Obviously, it is easy to calculate it by adding up salary and commission for each salesman. The query in Example 7 shows how to add two column values using SQL. Example 7 What is the total remuneration of the salespeople? SELECT ENAME, SAL+COMM FROM EMP WHERE JOB = SALESMAN ; ENAME SAL+COMM ALLEN 1900 WARD 1750 MARTIN 2650 TURNER 1500 Although SAL+COMM is not a column of table EMP, we can use it in a SE- LECT statement as if it were originally in the table, e.g. we can use it to specify WHERE clause conditions or base the output order on it. A list of the most commonly used arithmetic operators is given below. Operator Meaning Operator Meaning + Addition POWER Exponentiation Subtraction ROUND Rounding Multiplication TRUNC Truncation / Division ABS Absolute Value 4
5 Ordering Rows of Query Result Table We have seen earlier how we can influence the order of columns in the output of a query. Now, we will see how the order of rows can be changed by using the ORDER BY clause. If this clause is not specified in the SELECT statement, SQL decides internally upon the order of rows presented in a query output. Using ORDER BY, however, the rows of the output can be ordered according to column values. Example 8 illustrates the use of the ORDER BY clause. Example 8 List all employees in department 10, ordered by their salary SELECT * FROM EMP WHERE DEPTNO = 10 ORDER BY SAL; EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO 7934 MILLER CLERK JAN CLARK MANAGER JUN KING PRESIDENT 17-NOV If more than one column name is given in the ORDER BY clause, SQL sorts on the first given column, then on the second given column, and so on. By default rows are sorted in ascending order. This can be overridden by placing the keyword DESC after the column in the ORDER BY clause which we would like to be listed in descending order. Example 9 List all employees in the order of their jobs, and within that order in descending salary order. SELECT JOB, SAL, ENAME FROM EMP ORDER BY JOB, SAL DESC; JOB SAL ENAME ANALYST 3000 SCOTT ANALYST 3000 FORD CLERK 1300 MILLER CLERK 1100 ADAMS CLERK 950 JAMES CLERK 800 SMITH MANAGER 2975 JONES MANAGER 2850 BLAKE MANAGER 2450 CLARK PRESIDENT 5000 KING SALESMAN 1600 ALLEN SALESMAN 1500 TURNER SALESMAN 1250 WARD SALESMAN 1250 MARTIN 5
6 Functions on Groups of Rows Although the SELECT statement, as presented so far, has given us quite a powerful tool for querying a database, there are still a number of questions we may want to ask, but which we would find hard to formulate with our current knowledge of the SELECT statement. For example, we may be interested to know what is the highest salary in the company and who earns it, what is the lowest salary, what is the average salary, what is the total amount of commission paid to salesmen, how many managers are employed, and so on. The common factor of all these questions is that they can only be answered by looking at all rows of a table (EMP) as a single entity, rather than treating rows as individual pieces of information. The following functions are available. AVG( column-name ): Average (arithmetic mean) value of a column; COUNT( column-name ): Number of rows with a value not null for that column; MAX( column-name ): Maximum value of a column; MIN( column-name ): Minimum value of a column; SUM( column-name ): Sum of values of a column; Contrast these with the arithmetic functions described in Note 3. Those function were applied to individual values, whereas these are applied to sets of values. The following examples will demonstrate the use of these functions. Example 10? What is the average salary of all clerks employed in this company SELECT AVG(SAL) FROM EMP WHERE JOB = CLERK ; AVG(SAL) Example 11 How many analysts are working for this company? SELECT COUNT(*) FROM EMP WHERE JOB = ANALYST ; COUNT(*) 2 6
7 Example 12 What are the minimum and maximum commissions paid to salesman, and what is the total amount of commission paid by the company? SELECT MIN(COMM), MAX(COMM), SUM(COMM) FROM EMP WHERE JOB = SALESMAN ; MIN(COMM) MAX(COMM) SUM(COMM) These functions ignore NULL values. NULL values are used to represent attributes whose values are missing, unknown or not applicable. In the case that all values in a column are NULL, these functions return a special NULL value. The GROUP BY Clause An additional helpful feature, used in connection with the group functions discussed above, is the GROUP BY clause. Using this clause, we can perform functions such as AVG, COUNT, MAX, MIN and SUM on subsets of rows in a table so far we have used them only with respect to all rows in a table. It is often helpful to think of the GROUP BY clause as grouping the rows of an intermediate result in the evaluation of the query. In Example 13, below, we have to group the rows in EMP according to their DEPTNO values. Example 13 How much salary is paid by each department? SELECT DEPTNO, SUM(SAL) FROM EMP GROUP BY DEPTNO; DEPTNO SUM(SAL) We note the following points about the GROUP BY clause. A GROUP BY clause may also consist of two or more column identifiers. If grouping is required on a column which contains NULL values then these NULL values form one group. In the output, NULL value groups are presented first, whether the required ordering is ASCENDING or DESCENDING. 7
8 The HAVING Clause Similar to the WHERE clause, which allows us to select particular rows, we can use the HAVING clause to select particular groups of rows. Only results for those groups of rows are shown, which satisfy the condition given in the HAVING clause of a query. Let s say we are interested in the average salary of departments where nobody earns less than In order to answer this query, it is necessary to determine the lowest salary of each department, and then to eliminate all departments which have employees with a salary below Then we have to calculate the average salary values for the remaining departments. Example 14 shows a query which does all this. Example 14 What are the average salaries in departments where the minimum salary is greater than 1000? SELECT DEPTNO, AVG(SAL) FROM EMP GROUP BY DEPTNO HAVINGMIN(SAL) > 1000; DEPTNO AVG(SAL) We have now extended the SELECT statement by two more clauses. The new general form of the SELECT statement is shown in Figure 1. SELECT FROM WHERE GROUP BY HAVING ORDER BY column-names table-names search-condition column-name group-select-condition column-names Figure 1: The form of a SELECT statement with WHERE, GROUP BY and ORDER BY clauses. Further Reading Elmasri and Navathe, chapter 8, section 8.2. Ramakrishnan and Gehrke, Database Management Systems, chapter 5, sections 1 3 and 5. Chris Walton (adapted from a note by Rob Procter) 8
Chapter 1. Writing Basic. SQL Statements
Chapter 1 Writing Basic SQL Statements 1 Objectives After completing this lesson, you should be able to do the following: List the capabilities of SQL SELECT statements Execute a basic SELECT statement
More informationAggregating Data Using Group Functions
Aggregating Data Using Group Functions Objectives Capter 5 After completing this lesson, you should be able to do the following: Identify the available group functions Describe the use of group functions
More informationSubqueries Chapter 6
Subqueries Chapter 6 Objectives After completing this lesson, you should be able to do the follovving: Describe the types of problems that subqueries can solve Define subqueries List the types of subqueries
More informationProducing Readable Output with SQL*Plus
Producing Readable Output with SQL*Plus Chapter 8 Objectives After completing this lesson, you should be able to do the following: Produce queries that require an input variable Customize the SQL*Plus
More informationOracle SQL. Course Summary. Duration. Objectives
Oracle SQL Course Summary Identify the major structural components of the Oracle Database 11g Create reports of aggregated data Write SELECT statements that include queries Retrieve row and column data
More informationDisplaying Data from Multiple Tables. Chapter 4
Displaying Data from Multiple Tables Chapter 4 1 Objectives After completing this lesson, you should be able to do the following: Write SELECT statements to access data from more than one table using equality
More informationRelational Algebra. Query Languages Review. Operators. Select (σ), Project (π), Union ( ), Difference (-), Join: Natural (*) and Theta ( )
Query Languages Review Relational Algebra SQL Set operators Union Intersection Difference Cartesian product Relational Algebra Operators Relational operators Selection Projection Join Division Douglas
More informationSQL Introduction Chapter 7, sections 1 & 4. Introduction to SQL. Introduction to SQL. Introduction to SQL
SQL Introduction Chapter 7, sections 1 & 4 Objectives To understand Oracle s SQL client interface Understand the difference between commands to the interface and SQL language. To understand the Oracle
More informationConversion Functions
Conversion Functions Conversion functions convert a value from one datatype to another. Generally, the form of the function names follows the convention datatype TO datatype. The first datatype is the
More informationDatabase Design. Marta Jakubowska-Sobczak IT/ADC based on slides prepared by Paula Figueiredo, IT/DB
Marta Jakubowska-Sobczak IT/ADC based on slides prepared by Paula Figueiredo, IT/DB Outline Database concepts Conceptual Design Logical Design Communicating with the RDBMS 2 Some concepts Database: an
More informationOracle Database: SQL and PL/SQL Fundamentals
Oracle University Contact Us: 1.800.529.0165 Oracle Database: SQL and PL/SQL Fundamentals Duration: 5 Days What you will learn This course is designed to deliver the fundamentals of SQL and PL/SQL along
More informationDisplaying Data from Multiple Tables
Displaying Data from Multiple Tables 1 Objectives After completing this lesson, you should be able to do the following: Write SELECT statements to access data from more than one table using eguality and
More informationOracle Database: SQL and PL/SQL Fundamentals
Oracle University Contact Us: +966 12 739 894 Oracle Database: SQL and PL/SQL Fundamentals Duration: 5 Days What you will learn This Oracle Database: SQL and PL/SQL Fundamentals training is designed to
More informationOracle Database: SQL and PL/SQL Fundamentals NEW
Oracle University Contact Us: + 38516306373 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
More informationDavid L. Fuston, dfuston@vlamis.com Vlamis Software Solutions, Inc., www.vlamis.com
Data Warehouse and E-Business Intelligence ORACLE S SQL ANALYTIC FUNCTIONS IN 8i AND 9i David L. Fuston, dfuston@vlamis.com, www.vlamis.com INTRODUCTION The SQL language has traditionally provided little
More informationDatabase Access from a Programming Language: Database Access from a Programming Language
Database Access from a Programming Language: Java s JDBC Werner Nutt Introduction to Databases Free University of Bozen-Bolzano 2 Database Access from a Programming Language Two Approaches 1. Embedding
More informationDatabase Access from a Programming Language:
Database Access from a Programming Language: Java s JDBC Werner Nutt Introduction to Databases Free University of Bozen-Bolzano 2 Database Access from a Programming Language Two Approaches 1. Embedding
More informationRetrieval: Multiple Tables and Aggregation
4487CH08.qxd 11/24/04 10:15 AM Page 191 CHAPTER 8 Retrieval: Multiple Tables and Aggregation This chapter resumes the discussion of the retrieval possibilities of the SQL language. It is a logical continuation
More informationOracle/SQL Tutorial 1
Oracle/SQL Tutorial 1 Michael Gertz Database and Information Systems Group Department of Computer Science University of California, Davis gertz@cs.ucdavis.edu http://www.db.cs.ucdavis.edu This Oracle/SQL
More informationAppendix A Practices and Solutions
Appendix A Practices and Solutions Table of Contents Practices for Lesson I... 3 Practice I-1: Introduction... 4 Practice Solutions I-1: Introduction... 5 Practices for Lesson 1... 11 Practice 1-1: Retrieving
More informationChapter 1 Overview of the SQL Procedure
Chapter 1 Overview of the SQL Procedure 1.1 Features of PROC SQL...1-3 1.2 Selecting Columns and Rows...1-6 1.3 Presenting and Summarizing Data...1-17 1.4 Joining Tables...1-27 1-2 Chapter 1 Overview of
More informationSQL*Plus User s Guide and Reference
SQL*Plus User s Guide and Reference Release 8.0 Part No. A53717 01 Enabling the Information Age SQL*Plus User s Guide and Reference, Release 8.0 Part No. A53717 01 Copyright 1997 Oracle Corporation All
More informationData Models and Database Management Systems (DBMSs) Dr. Philip Cannata
Data Models and Database Management Systems (DBMSs) Dr. Philip Cannata 1 Data Models in the 1960s, 1970s, and 1980s Hierarchical Network (Graph) Relational Schema (Model) - first 1956 Vern Watts was IMS's
More informationOracle 12c New Features For Developers
Oracle 12c New Features For Developers Presented by: John Jay King Download this paper from: 1 Session Objectives Learn new Oracle 12c features that are geared to developers Know how existing database
More informationOracle Database 11g SQL
AO3 - Version: 2 19 June 2016 Oracle Database 11g SQL Oracle Database 11g SQL AO3 - Version: 2 3 days Course Description: This course provides the essential SQL skills that allow developers to write queries
More informationRetrieving Data Using the SQL SELECT Statement. Copyright 2006, Oracle. All rights reserved.
Retrieving Data Using the SQL SELECT Statement Objectives After completing this lesson, you should be able to do the following: List the capabilities of SQL SELECT statements Execute a basic SELECT statement
More informationIntroduction to Microsoft Jet SQL
Introduction to Microsoft Jet SQL Microsoft Jet SQL is a relational database language based on the SQL 1989 standard of the American Standards Institute (ANSI). Microsoft Jet SQL contains two kinds of
More informationOracle Database: Introduction to SQL
Oracle University Contact Us: +381 11 2016811 Oracle Database: Introduction to SQL Duration: 5 Days What you will learn Understanding the basic concepts of relational databases ensure refined code by developers.
More informationProgramming with SQL
Unit 43: Programming with SQL Learning Outcomes A candidate following a programme of learning leading to this unit will be able to: Create queries to retrieve information from relational databases using
More informationDuration Vendor Audience 5 Days Oracle End Users, Developers, Technical Consultants and Support Staff
D80198GC10 Oracle Database 12c SQL and Fundamentals Summary Duration Vendor Audience 5 Days Oracle End Users, Developers, Technical Consultants and Support Staff Level Professional Delivery Method Instructor-led
More informationOracle Database: Introduction to SQL
Oracle University Contact Us: 1.800.529.0165 Oracle Database: Introduction to SQL Duration: 5 Days What you will learn This Oracle Database: Introduction to SQL training teaches you how to write subqueries,
More informationOracle Database: Introduction to SQL
Oracle University Contact Us: 1.800.529.0165 Oracle Database: Introduction to SQL Duration: 5 Days What you will learn View a newer version of this course This Oracle Database: Introduction to SQL training
More informationExamine the structure of the EMPLOYEES table: EMPLOYEE_ID NUMBER Primary Key FIRST_NAME VARCHAR2(25) LAST_NAME VARCHAR2(25)
Examine the structure of the EMPLOYEES table: EMPLOYEE_ID NUMBER Primary Key FIRST_NAME VARCHAR2(25) LAST_NAME VARCHAR2(25) Which three statements inserts a row into the table? A. INSERT INTO employees
More informationOracle Database: SQL and PL/SQL Fundamentals NEW
Oracle University Contact Us: 001-855-844-3881 & 001-800-514-06-97 Oracle Database: SQL and PL/SQL Fundamentals NEW Duration: 5 Days What you will learn This Oracle Database: SQL and PL/SQL Fundamentals
More informationCOMP 5138 Relational Database Management Systems. Week 5 : Basic SQL. Today s Agenda. Overview. Basic SQL Queries. Joins Queries
COMP 5138 Relational Database Management Systems Week 5 : Basic COMP5138 "Relational Database Managment Systems" J. Davis 2006 5-1 Today s Agenda Overview Basic Queries Joins Queries Aggregate Functions
More information2874CD1EssentialSQL.qxd 6/25/01 3:06 PM Page 1 Essential SQL Copyright 2001 SYBEX, Inc., Alameda, CA www.sybex.com
Essential SQL 2 Essential SQL This bonus chapter is provided with Mastering Delphi 6. It is a basic introduction to SQL to accompany Chapter 14, Client/Server Programming. RDBMS packages are generally
More informationOracle Database 12c: Introduction to SQL Ed 1.1
Oracle University Contact Us: 1.800.529.0165 Oracle Database 12c: Introduction to SQL Ed 1.1 Duration: 5 Days What you will learn This Oracle Database: Introduction to SQL training helps you write subqueries,
More informationIntroduction to SQL: Data Retrieving
Introduction to SQL: Data Retrieving Ruslan Fomkin Databasdesign för Ingenjörer 1056F Structured Query Language (SQL) History: SEQUEL (Structured English QUery Language), earlier 70 s, IBM Research SQL
More information1 Structured Query Language: Again. 2 Joining Tables
1 Structured Query Language: Again So far we ve only seen the basic features of SQL. More often than not, you can get away with just using the basic SELECT, INSERT, UPDATE, or DELETE statements. Sometimes
More informationPart A: Data Definition Language (DDL) Schema and Catalog CREAT TABLE. Referential Triggered Actions. CSC 742 Database Management Systems
CSC 74 Database Management Systems Topic #0: SQL Part A: Data Definition Language (DDL) Spring 00 CSC 74: DBMS by Dr. Peng Ning Spring 00 CSC 74: DBMS by Dr. Peng Ning Schema and Catalog Schema A collection
More informationIT2305 Database Systems I (Compulsory)
Database Systems I (Compulsory) INTRODUCTION This is one of the 4 modules designed for Semester 2 of Bachelor of Information Technology Degree program. CREDITS: 04 LEARNING OUTCOMES On completion of this
More information- Eliminating redundant data - Ensuring data dependencies makes sense. ie:- data is stored logically
Normalization of databases Database normalization is a technique of organizing the data in the database. Normalization is a systematic approach of decomposing tables to eliminate data redundancy and undesirable
More informationSQL Basics. Introduction to Standard Query Language
SQL Basics Introduction to Standard Query Language SQL What Is It? Structured Query Language Common Language For Variety of Databases ANSI Standard BUT. Two Types of SQL DML Data Manipulation Language
More informationOracle Database 10g: Introduction to SQL
Oracle University Contact Us: 1.800.529.0165 Oracle Database 10g: Introduction to SQL Duration: 5 Days What you will learn This course offers students an introduction to Oracle Database 10g database technology.
More informationSQL> SELECT ename, job, sal Salary. 1.4.Will the SELECT statement execute successfully? True/False
BASES DE DATOS Ingeniería Técnica Informática Asignatura Obligatoria: 4.5 + 4.5 créditos (Segundo cuatrimestre) Curso académico 2000/2002 Relación de Ejercicios Prácticos TEMA 1. MANDATO SELECT BÁSICO
More informationInformation and Computer Science Department ICS 324 Database Systems Lab#11 SQL-Basic Query
Information and Computer Science Department ICS 324 Database Systems Lab#11 SQL-Basic Query Objectives The objective of this lab is to learn the query language of SQL. Outcomes After completing this Lab,
More informationDavid M. Kroenke and David J. Auer Database Processing: Fundamentals, Design and Implementation
David M. Kroenke and David J. Auer Database Processing: Fundamentals, Design and Implementation Chapter Two: Introduction to Structured Query Language 2-1 Chapter Objectives To understand the use of extracted
More informationRDBMS Using Oracle. Lecture Week 7 Introduction to Oracle 9i SQL Last Lecture. kamran.munir@gmail.com. Joining Tables
RDBMS Using Oracle Lecture Week 7 Introduction to Oracle 9i SQL Last Lecture Joining Tables Multiple Table Queries Simple Joins Complex Joins Cartesian Joins Outer Joins Multi table Joins Other Multiple
More informationDatabase Query 1: SQL Basics
Database Query 1: SQL Basics CIS 3730 Designing and Managing Data J.G. Zheng Fall 2010 1 Overview Using Structured Query Language (SQL) to get the data you want from relational databases Learning basic
More informationMONASH UNIVERSITY. Faculty of Information Technology
CSE2132/CSE9002 - Tutorial 1 Database Concept Exercises TOPICS - Database Concepts; Introduction to Oracle Part 1 (To be done in the students own time then discussed in class if necessary.) Hoffer,Prescott
More informationUsing Multiple Operations. Implementing Table Operations Using Structured Query Language (SQL)
Copyright 2000-2001, University of Washington Using Multiple Operations Implementing Table Operations Using Structured Query Language (SQL) The implementation of table operations in relational database
More informationUsing SQL in RPG Programs: An Introduction
Using SQL in RPG Programs: An Introduction OCEAN Technical Conference Catch the Wave Susan M. Gantner susan.gantner @ partner400.com www.partner400.com Your partner in AS/400 and iseries Education Copyright
More informationSQL - QUICK GUIDE. Allows users to access data in relational database management systems.
http://www.tutorialspoint.com/sql/sql-quick-guide.htm SQL - QUICK GUIDE Copyright tutorialspoint.com What is SQL? SQL is Structured Query Language, which is a computer language for storing, manipulating
More informationT-SQL STANDARD ELEMENTS
T-SQL STANDARD ELEMENTS SLIDE Overview Types of commands and statement elements Basic SELECT statements Categories of T-SQL statements Data Manipulation Language (DML*) Statements for querying and modifying
More informationIT2304: Database Systems 1 (DBS 1)
: Database Systems 1 (DBS 1) (Compulsory) 1. OUTLINE OF SYLLABUS Topic Minimum number of hours Introduction to DBMS 07 Relational Data Model 03 Data manipulation using Relational Algebra 06 Data manipulation
More informationNetezza SQL Class Outline
Netezza SQL Class Outline CoffingDW education has been customized for every customer for the past 20 years. Our classes can be taught either on site or remotely via the internet. Education Contact: John
More informationAd Hoc Advanced Table of Contents
Ad Hoc Advanced Table of Contents Functions... 1 Adding a Function to the Adhoc Query:... 1 Constant... 2 Coalesce... 4 Concatenate... 6 Add/Subtract... 7 Logical Expressions... 8 Creating a Logical Expression:...
More informationSUBQUERIES AND VIEWS. CS121: Introduction to Relational Database Systems Fall 2015 Lecture 6
SUBQUERIES AND VIEWS CS121: Introduction to Relational Database Systems Fall 2015 Lecture 6 String Comparisons and GROUP BY 2! Last time, introduced many advanced features of SQL, including GROUP BY! Recall:
More informationInstant SQL Programming
Instant SQL Programming Joe Celko Wrox Press Ltd. INSTANT Table of Contents Introduction 1 What Can SQL Do for Me? 2 Who Should Use This Book? 2 How To Use This Book 3 What You Should Know 3 Conventions
More informationP_Id LastName FirstName Address City 1 Kumari Mounitha VPura Bangalore 2 Kumar Pranav Yelhanka Bangalore 3 Gubbi Sharan Hebbal Tumkur
SQL is a standard language for accessing and manipulating databases. What is SQL? SQL stands for Structured Query Language SQL lets you access and manipulate databases SQL is an ANSI (American National
More informationSQL the natural language for analysis ORACLE WHITE PAPER JUNE 2015
SQL the natural language for analysis ORACLE WHITE PAPER JUNE 2015 Contents Overview 1 Introduction 1 Powerful Framework 1 Simplified Optimization 6 Continuous Evolution 8 Standards Based 9 Why Oracle
More informationSQL. Short introduction
SQL Short introduction 1 Overview SQL, which stands for Structured Query Language, is used to communicate with a database. Through SQL one can create, manipulate, query and delete tables and contents.
More information2. DECODE Function, CASE Expression
DECODE Function, CASE Expression 2.1 2. DECODE Function, CASE Expression Introduction to DECODE DECODE Examples Contrast with 9i Case Statement CASE Examples CASE Histograms SKILLBUILDERS DECODE Function,
More informationIntroduction to Proc SQL Steven First, Systems Seminar Consultants, Madison, WI
Paper #HW02 Introduction to Proc SQL Steven First, Systems Seminar Consultants, Madison, WI ABSTRACT PROC SQL is a powerful Base SAS Procedure that combines the functionality of DATA and PROC steps into
More informationIntroduction to SQL and SQL in R. LISA Short Courses Xinran Hu
Introduction to SQL and SQL in R LISA Short Courses Xinran Hu 1 Laboratory for Interdisciplinary Statistical Analysis LISA helps VT researchers benefit from the use of Statistics Collaboration: Visit our
More informationWelcome to the topic on queries in SAP Business One.
Welcome to the topic on queries in SAP Business One. 1 In this topic, you will learn to create SQL queries using the SAP Business One query tools Query Wizard and Query Generator. You will also see how
More informationMicrosoft Access Lesson 5: Structured Query Language (SQL)
Microsoft Access Lesson 5: Structured Query Language (SQL) Structured Query Language (pronounced S.Q.L. or sequel ) is a standard computing language for retrieving information from and manipulating databases.
More informationDate / Time Arithmetic with Oracle
Date / Time Arithmetic with Oracle If you store date and time information in Oracle, you have two different options for the column's datatype - DATE and TIMESTAMP. DATE is the datatype that we are all
More informationCHAPTER 2 DATABASE MANAGEMENT SYSTEM AND SECURITY
CHAPTER 2 DATABASE MANAGEMENT SYSTEM AND SECURITY 2.1 Introduction In this chapter, I am going to introduce Database Management Systems (DBMS) and the Structured Query Language (SQL), its syntax and usage.
More informationChapter 9 Joining Data from Multiple Tables. Oracle 10g: SQL
Chapter 9 Joining Data from Multiple Tables Oracle 10g: SQL Objectives Identify a Cartesian join Create an equality join using the WHERE clause Create an equality join using the JOIN keyword Create a non-equality
More informationPerforming Queries Using PROC SQL (1)
SAS SQL Contents Performing queries using PROC SQL Performing advanced queries using PROC SQL Combining tables horizontally using PROC SQL Combining tables vertically using PROC SQL 2 Performing Queries
More informationMicrosoft Access 3: Understanding and Creating Queries
Microsoft Access 3: Understanding and Creating Queries In Access Level 2, we learned how to perform basic data retrievals by using Search & Replace functions and Sort & Filter functions. For more complex
More informationAN INTRODUCTION TO THE SQL PROCEDURE Chris Yindra, C. Y. Associates
AN INTRODUCTION TO THE SQL PROCEDURE Chris Yindra, C Y Associates Abstract This tutorial will introduce the SQL (Structured Query Language) procedure through a series of simple examples We will initially
More informationHandling Missing Values in the SQL Procedure
Handling Missing Values in the SQL Procedure Danbo Yi, Abt Associates Inc., Cambridge, MA Lei Zhang, Domain Solutions Corp., Cambridge, MA ABSTRACT PROC SQL as a powerful database management tool provides
More informationRelational Database: Additional Operations on Relations; SQL
Relational Database: Additional Operations on Relations; SQL Greg Plaxton Theory in Programming Practice, Fall 2005 Department of Computer Science University of Texas at Austin Overview The course packet
More informationUsing AND in a Query: Step 1: Open Query Design
Using AND in a Query: Step 1: Open Query Design From the Database window, choose Query on the Objects bar. The list of saved queries is displayed, as shown in this figure. Click the Design button. The
More informationKatie Minten Ronk, Steve First, David Beam Systems Seminar Consultants, Inc., Madison, WI
Paper 191-27 AN INTRODUCTION TO PROC SQL Katie Minten Ronk, Steve First, David Beam Systems Seminar Consultants, Inc., Madison, WI ABSTRACT PROC SQL is a powerful Base SAS 7 Procedure that combines the
More informationIntro to Embedded SQL Programming for ILE RPG Developers
Intro to Embedded SQL Programming for ILE RPG Developers Dan Cruikshank DB2 for i Center of Excellence 1 Agenda Reasons for using Embedded SQL Getting started with Embedded SQL Using Host Variables Using
More informationSES Project v 9.0 SES/CAESAR QUERY TOOL. Running and Editing Queries. PS Query
SES Project v 9.0 SES/CAESAR QUERY TOOL Running and Editing Queries PS Query Table Of Contents I - Introduction to Query:... 3 PeopleSoft Query Overview:... 3 Query Terminology:... 3 Navigation to Query
More informationDatabase Programming with PL/SQL: Learning Objectives
Database Programming with PL/SQL: Learning Objectives This course covers PL/SQL, a procedural language extension to SQL. Through an innovative project-based approach, students learn procedural logic constructs
More informationhttp://www.thedataanalysis.com/sql/sql-programming.html
http://www.thedataanalysis.com/sql/sql-programming.html SQL: UPDATE Statement The UPDATE statement allows you to update a single record or multiple records in a table. The syntax for the UPDATE statement
More informationHistory of SQL. Relational Database Languages. Tuple relational calculus ALPHA (Codd, 1970s) QUEL (based on ALPHA) Datalog (rule-based, like PROLOG)
Relational Database Languages Tuple relational calculus ALPHA (Codd, 1970s) QUEL (based on ALPHA) Datalog (rule-based, like PROLOG) Domain relational calculus QBE (used in Access) History of SQL Standards:
More informationUnit 10: Microsoft Access Queries
Microsoft Access Queries Unit 10: Microsoft Access Queries Introduction Queries are a fundamental means of accessing and displaying data from tables. Queries used to view, update, and analyze data in different
More informationSQL SELECT Query: Intermediate
SQL SELECT Query: Intermediate IT 4153 Advanced Database J.G. Zheng Spring 2012 Overview SQL Select Expression Alias revisit Aggregate functions - complete Table join - complete Sub-query in where Limiting
More informationMini User's Guide for SQL*Plus T. J. Teorey
Mini User's Guide for SQL*Plus T. J. Teorey Table of Contents Oracle/logging-in 1 Nested subqueries 5 SQL create table/naming rules 2 Complex functions 6 Update commands 3 Save a query/perm table 6 Select
More informationLecture 25: Database Notes
Lecture 25: Database Notes 36-350, Fall 2014 12 November 2014 The examples here use http://www.stat.cmu.edu/~cshalizi/statcomp/ 14/lectures/23/baseball.db, which is derived from Lahman s baseball database
More informationRelational Algebra and SQL
Relational Algebra and SQL Johannes Gehrke johannes@cs.cornell.edu http://www.cs.cornell.edu/johannes Slides from Database Management Systems, 3 rd Edition, Ramakrishnan and Gehrke. Database Management
More informationChapter 8. SQL-99: SchemaDefinition, Constraints, and Queries and Views
Chapter 8 SQL-99: SchemaDefinition, Constraints, and Queries and Views Data Definition, Constraints, and Schema Changes Used to CREATE, DROP, and ALTER the descriptions of the tables (relations) of a database
More informationUsing the SQL Procedure
Using the SQL Procedure Kirk Paul Lafler Software Intelligence Corporation Abstract The SQL procedure follows most of the guidelines established by the American National Standards Institute (ANSI). In
More informationOracle For Beginners Page : 1
Oracle For Beginners Page : 1 Chapter 22 OBJECT TYPES Introduction to object types Creating object type and object Using object type Creating methods Accessing objects using SQL Object Type Dependencies
More information3.GETTING STARTED WITH ORACLE8i
Oracle For Beginners Page : 1 3.GETTING STARTED WITH ORACLE8i Creating a table Datatypes Displaying table definition using DESCRIBE Inserting rows into a table Selecting rows from a table Editing SQL buffer
More informationChapter 5 More SQL: Complex Queries, Triggers, Views, and Schema Modification
Chapter 5 More SQL: Complex Queries, Triggers, Views, and Schema Modification Copyright 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 5 Outline More Complex SQL Retrieval Queries
More informationUnit 3. Retrieving Data from Multiple Tables
Unit 3. Retrieving Data from Multiple Tables What This Unit Is About How to retrieve columns from more than one table or view. What You Should Be Able to Do Retrieve data from more than one table or view.
More informationCreating QBE Queries in Microsoft SQL Server
Creating QBE Queries in Microsoft SQL Server When you ask SQL Server or any other DBMS (including Access) a question about the data in a database, the question is called a query. A query is simply a question
More informationThe Power of DECODE()
The Power of DECODE() Doug Burns Note - this document discusses the use of the DECODE function to develop more efficient SQL queries. However, if you're using Oracle 8.1.6 or greater, you should really
More informationChapter 5. SQL: Queries, Constraints, Triggers
Chapter 5 SQL: Queries, Constraints, Triggers 1 Overview: aspects of SQL DML: Data Management Language. Pose queries (Ch. 5) and insert, delete, modify rows (Ch. 3) DDL: Data Definition Language. Creation,
More informationSQL Server 2008 Core Skills. Gary Young 2011
SQL Server 2008 Core Skills Gary Young 2011 Confucius I hear and I forget I see and I remember I do and I understand Core Skills Syllabus Theory of relational databases SQL Server tools Getting help Data
More informationQuery 4. Lesson Objectives 4. Review 5. Smart Query 5. Create a Smart Query 6. Create a Smart Query Definition from an Ad-hoc Query 9
TABLE OF CONTENTS Query 4 Lesson Objectives 4 Review 5 Smart Query 5 Create a Smart Query 6 Create a Smart Query Definition from an Ad-hoc Query 9 Query Functions and Features 13 Summarize Output Fields
More informationObjectives of SQL. Terminology for Relational Model. Introduction to SQL
Karlstad University Department of Information Systems Adapted for a textbook by Date C. J. An Introduction to Database Systems Pearson Addison Wesley, 2004 Introduction to SQL Remigijus GUSTAS Phone: +46-54
More informationStructured Query Language (SQL)
Objectives of SQL Structured Query Language (SQL) o Ideally, database language should allow user to: create the database and relation structures; perform insertion, modification, deletion of data from
More information