Retrieving Data Using the SQL SELECT Statement. Copyright 2004, Oracle. All rights reserved.

Similar documents
Retrieving Data Using the SQL SELECT Statement. Copyright 2004, Oracle. All rights reserved.

Retrieving Data Using the SQL SELECT Statement. Copyright 2009, Oracle. All rights reserved.

RETRIEVING DATA USING THE SQL SELECT STATEMENT

Oracle Database 10g: SQL Fundamentals I

Database Programming with SQL

GIFT Department of Computing Science Data Selection and Filtering using the SELECT Statement

Restricting and Sorting Data. Copyright 2004, Oracle. All rights reserved.

Oracle Database 10g: SQL Fundamentals I

Working with Columns, Characters and Rows. Copyright 2008, Oracle. All rights reserved.

Database Foundations. 6-4 Data Manipulation Language (DML) Copyright 2015, Oracle and/or its affiliates. All rights reserved.

Restricting and Sorting Data. Copyright 2004, Oracle. All rights reserved.

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

Manipulating Data. Copyright 2004, Oracle. All rights reserved.

SELF TEST. List the Capabilities of SQL SELECT Statements

Limit Rows Selected. Copyright 2008, Oracle. All rights reserved.

Using the Set Operators. Copyright 2006, Oracle. All rights reserved.

Data Manipulation Language

Creating Other Schema Objects

Using the Set Operators. Copyright 2004, Oracle. All rights reserved.

RESTRICTING AND SORTING DATA

EXISTS NOT EXISTS WITH

Institute of Aga. Network Database LECTURER NIYAZ M. SALIH

Táblák tartalmának módosítása. Copyright 2004, Oracle. All rights reserved.

Displaying Data from Multiple Tables. Copyright 2004, Oracle. All rights reserved.

Join, Sub queries and set operators

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

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

Alkérdések II. Copyright 2004, Oracle. All rights reserved.

Sun Certified MySQL Associate

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

Intermediate SQL: Aggregated Data, Joins and Set Operators

Creating Other Schema Objects. Copyright 2004, Oracle. All rights reserved.

Bsc (Hons) Software Engineering. Examinations for / Semester 1. Resit Examinations for BSE/15A/FT & BSE/16A/FT

DUE: 9. Create a query that will return the average order total for all Global Fast Foods orders from January 1, 2002, to December 21, 2002.

Aggregate Functions. Eng. Mohammed Alokshiya. Islamic University of Gaza. Faculty of Engineering. Computer Engineering Dept. Database Lab (ECOM 4113)

ITCertMaster. Safe, simple and fast. 100% Pass guarantee! IT Certification Guaranteed, The Easy Way!

Introduction to Oracle9i: SQL

Course Overview. Copyright 2010, Oracle and/or its affiliates. All rights reserved.

Database Programming - Section 18. Instructor Guide

Using DbVisualizer Variables

KORA. RDBMS Concepts II

Database Foundations. 6-9 Joining Tables Using JOIN. Copyright 2014, Oracle and/or its affiliates. All rights reserved.

Oracle Database 10g: Introduction to SQL

Oracle 1Z Oracle Database 11g : SQL Fundamentals I. Download Full Version :

DATA CONSTRAINT. Prepared By: Dr. Vipul Vekariya

Relational Database Management Systems for Epidemiologists: SQL Part I

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

Retrieving Data from Multiple Tables

Database Programming with SQL

What Are Group Functions? Reporting Aggregated Data Using the Group Functions. Objectives. Types of Group Functions

DEFAULT Values, MERGE, and Multi-Table Inserts. Copyright 2009, Oracle. All rights reserved.

Unit 4. Scalar Functions and Arithmetic

Database Programming with SQL

Oracle Database SQL Basics

Querying Data with Transact SQL

Using DDL Statements to Create and Manage Tables. Copyright 2004, Oracle. All rights reserved.

chapter 2 G ETTING I NFORMATION FROM A TABLE

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

ÇALIŞMA TEST SORULARI

Using DDL Statements to Create and Manage Tables. Copyright 2004, Oracle. All rights reserved.

1 Writing Basic SQL SELECT Statements 2 Restricting and Sorting Data

Database Foundations. 6-3 Data Definition Language (DDL) Copyright 2015, Oracle and/or its affiliates. All rights reserved.

GIFT Department of Computing Science. CS-217/224: Database Systems. Lab-5 Manual. Displaying Data from Multiple Tables - SQL Joins

Conversion Functions

Oracle Syllabus Course code-r10605 SQL

Database Programming with PL/SQL

A. It executes successfully and displays rows in the descending order of PROMO_CATEGORY.

PASS4TEST. IT Certification Guaranteed, The Easy Way! We offer free update service for one year

license to use this Student Guide

Oracle Database: Introduction to SQL Ed 2

Database Programming with PL/SQL

Oracle Database 11g: SQL Fundamentals I

Database Programming with SQL

normalization are being violated o Apply the rule of Third Normal Form to resolve a violation in the model

Oracle Database 11g: SQL and PL/SQL Fundamentals

Getting Information from a Table

SQL functions fit into two broad categories: Data definition language Data manipulation language

QMF: Query Management Facility

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

Objectives. After completing this lesson, you should be able to do the following:

HR Database. Sample Output from TechWriter 2007 for Databases

Assignment Grading Rubric

Chapter 9: Working With Data

CS 275 Winter 2011 Problem Set 3

Oracle Database: SQL and PL/SQL Fundamentals NEW

c) Comments do not cause any machine language object code to be generated. d) Lengthy comments can cause poor execution-time performance.

Relational Database Languages

Oracle_CertifyMe_1Z0-051_v _180q_By-steeve

Oracle Database: SQL and PL/SQL Fundamentals Ed 2

History of SQL. Relational Database Languages. Tuple relational calculus ALPHA (Codd, 1970s) QUEL (based on ALPHA) Datalog (rule-based, like PROLOG)

1Z Oracle Database 11g - SQL Fundamentals I Exam Summary Syllabus Questions

Language. f SQL. Larry Rockoff COURSE TECHNOLOGY. Kingdom United States. Course Technology PTR. A part ofcenqaqe Learninq

Oracle Database: SQL Fundamentals I. Oracle Internal & Oracle Academy Use Only. Volume II Student Guide. D64258GC10 Edition 1.0 January 2010 D65028

Oracle MOOC: SQL Fundamentals

Reporting Aggregated Data Using the Group Functions. Copyright 2004, Oracle. All rights reserved.

Lab # 6. Using Subqueries and Set Operators. Eng. Alaa O Shama

Database Programming with PL/SQL

Database Programming - Section 7. Instructor Guide

Database Programming with SQL

Database Design & Programming with SQL: Part 1 Learning Objectives

Transcription:

Retrieving Data Using the SQL SELECT Statement Copyright 2004, Oracle. All rights reserved.

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 1-2 Copyright 2004, Oracle. All rights reserved.

Capabilities of SQL SELECT Statements Projection Selection Table 1 Table 1 Join Table 1 Table 2 1-3 Copyright 2004, Oracle. All rights reserved.

Basic SELECT Statement SELECT * {[DISTINCT] column expression [alias],...} FROM table; SELECT identifies the columns to be displayed FROM identifies the table containing those columns 1-4 Copyright 2004, Oracle. All rights reserved.

Selecting All Columns SELECT * FROM departments; 1-5 Copyright 2004, Oracle. All rights reserved.

Selecting Specific Columns SELECT department_id, location_id FROM departments; 1-6 Copyright 2004, Oracle. All rights reserved.

Writing SQL Statements SQL statements are not case-sensitive. SQL statements can be on one or more lines. Keywords cannot be abbreviated or split across lines. Clauses are usually placed on separate lines. Indents are used to enhance readability. 1-7 Copyright 2004, Oracle. All rights reserved.

Arithmetic Expressions Create expressions with number and date data by using arithmetic operators. Operator + Add Description - Subtract * Multiply / Divide 1-8 Copyright 2004, Oracle. All rights reserved.

Using Arithmetic Operators SELECT last_name, salary, salary + 300 1-9 Copyright 2004, Oracle. All rights reserved.

Operator Precedence SELECT last_name, salary, 12*salary+100 1 SELECT last_name, salary, 12*(salary+100) 2 1-10 Copyright 2004, Oracle. All rights reserved.

Defining a Null Value A null is a value that is unavailable, unassigned, unknown, or inapplicable. A null is not the same as a zero or a blank space. SELECT last_name, job_id, salary, commission_pct 1-11 Copyright 2004, Oracle. All rights reserved.

Null Values in Arithmetic Expressions Arithmetic expressions containing a null value evaluate to null. SELECT last_name, 12*salary*commission_pct 1-12 Copyright 2004, Oracle. All rights reserved.

Defining a Column Alias A column alias: Renames a column heading Is useful with calculations Immediately follows the column name (There can also be the optional AS keyword between the column name and alias.) Requires double quotation marks if it contains spaces or special characters or if it is casesensitive 1-13 Copyright 2004, Oracle. All rights reserved.

Using Column Aliases SELECT last_name AS name, commission_pct comm SELECT last_name "Name", salary*12 "Annual Salary" 1-14 Copyright 2004, Oracle. All rights reserved.

Concatenation Operator A concatenation operator: Links columns or character strings to other columns Is represented by two vertical bars ( ) Creates a resultant column that is a character expression SELECT last_name job_id AS "Employees" 1-15 Copyright 2004, Oracle. All rights reserved.

Literal Character Strings A literal is a character, a number, or a date that is included in the SELECT statement. Date and character literal values must be enclosed by single quotation marks. Each character string is output once for each row returned. 1-16 Copyright 2004, Oracle. All rights reserved.

Using Literal Character Strings SELECT last_name ' is a ' job_id AS "Employee Details" 1-17 Copyright 2004, Oracle. All rights reserved.

Alternative Quote (q) Operator Specify your own quotation mark delimiter Choose any delimiter Increase readability and usability SELECT department_name q'[, it's assigned Manager Id: ]' manager_id AS "Department and Manager" FROM departments; 1-18 Copyright 2004, Oracle. All rights reserved.

Duplicate Rows The default display of queries is all rows, including duplicate rows. SELECT department_id 1 SELECT DISTINCT department_id 2 1-19 Copyright 2004, Oracle. All rights reserved.

Summary In this lesson, you should have learned how to: Write a SELECT statement that: Returns all rows and columns from a table Returns specified columns from a table Uses column aliases to display more descriptive column headings SELECT * {[DISTINCT] column expression [alias],...} FROM table; 1-20 Copyright 2004, Oracle. All rights reserved.