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

Oracle Database 10g: SQL Fundamentals I

Database Programming with SQL

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

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

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.

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

Restricting and Sorting 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.

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

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

Creating Other Schema Objects

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

EXISTS NOT EXISTS WITH

Data Manipulation Language

Relational Database Management Systems for Epidemiologists: SQL Part I

Oracle Database 10g: Introduction to SQL

RESTRICTING AND SORTING DATA

Database Programming - Section 18. Instructor Guide

Institute of Aga. Network Database LECTURER NIYAZ M. SALIH

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

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

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

Sun Certified MySQL Associate

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

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

Join, Sub queries and set operators

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

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

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

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

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

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

Using DbVisualizer Variables

Intermediate SQL: Aggregated Data, Joins and Set Operators

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

chapter 2 G ETTING I NFORMATION FROM A TABLE

Database Programming with PL/SQL

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.

Database Programming with SQL

Introduction to Oracle9i: SQL

1 Writing Basic SQL SELECT Statements 2 Restricting and Sorting Data

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

Unit 4. Scalar Functions and Arithmetic

KORA. RDBMS Concepts II

Database Programming with SQL

license to use this Student Guide

DATA CONSTRAINT. Prepared By: Dr. Vipul Vekariya

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

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

Full file at C How to Program, 6/e Multiple Choice Test Bank

Querying Data with Transact SQL

Retrieving Data from Multiple Tables

Oracle Database 11g: SQL and PL/SQL Fundamentals

QMF: Query Management Facility

Oracle Database SQL Basics

Getting Information from a Table

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.

Introduction to Oracle9i: SQL Basics

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

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

Oracle Database 10g: SQL Fundamentals I

Oracle Database: Introduction to SQL Ed 2

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

Oracle Database: SQL and PL/SQL Fundamentals NEW

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

ÇALIŞMA TEST SORULARI

Oracle Database 11g: SQL Fundamentals I

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

Oracle Database: SQL and PL/SQL Fundamentals Ed 2

CSC Web Programming. Introduction to SQL

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

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

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

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

Conversion Functions

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

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

Assignment Grading Rubric

Table of Contents. PDF created with FinePrint pdffactory Pro trial version

Oracle Syllabus Course code-r10605 SQL

Relational Database Languages

Chapter 9: Working With Data

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

BraindumpsVCE. Best vce braindumps-exam vce pdf free download

Oracle Database 11g: PL/SQL Fundamentals

Oracle_CertifyMe_1Z0-051_v _180q_By-steeve

Oracle Database 11g: SQL Fundamentals I COPYRIGHTED MATERIAL. PArt

Database Programming with PL/SQL

Database Programming with PL/SQL

Oracle Database 10g: SQL Fundamentals I

Database Programming with SQL

HNDIT 1105 Database Management Systems

5. Single-row function

Transcription:

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 Differentiate between SQL statements and isql*plus commands

Capabilities of SQL SELECT Statements Projection Selection Table 1 Table 1 Join Table 1 Table 2

Basic SELECT Statement SELECT * {[DISTINCT] column expression [alias],...} FROM table; SELECT identifies the columns to be displayed FROM identifies the table containing those columns

Selecting All Columns SELECT * FROM departments;

Selecting Specific Columns SELECT department_id, location_id FROM departments;

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. In isql*plus, SQL statements can optionally be terminated by a semicolon (;). Semicolons are required if you execute multiple SQL statements. In SQL*plus, you are required to end each SQL statement with a semicolon (;).

Column Heading Defaults isql*plus: Default heading alignment: Center Default heading display: Uppercase SQL*Plus: Character and Date column headings are leftaligned Number column headings are right-aligned Default heading display: Uppercase

Arithmetic Expressions Create expressions with number and date data by using arithmetic operators. Operator + - * / Description Add Subtract Multiply Divide

Using Arithmetic Operators SELECT last_name, salary, salary + 300 FROM employees;

Operator Precedence SELECT last_name, salary, 12*salary+100 FROM employees; 1 SELECT last_name, salary, 12*(salary+100) FROM employees; 2

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 FROM employees;

Null Values in Arithmetic Expressions Arithmetic expressions containing a null value evaluate to null. SELECT last_name, 12*salary*commission_pct FROM employees;

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

Using Column Aliases SELECT last_name AS name, commission_pct comm FROM employees; SELECT last_name "Name", salary*12 "Annual Salary" FROM employees;

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 FROM last_name job_id AS "Employees" employees;

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.

Using Literal Character Strings SELECT last_name ' is a ' job_id AS "Employee Details" FROM employees;

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;

Duplicate Rows The default display of queries is all rows, including duplicate rows. SELECT department_id FROM employees; 1 SELECT DISTINCT department_id FROM employees; 2