1 ORACLE I 3 – SQL 1 Salim Phone: 0815-188-2384 YM: talim_bansal.

Slides:



Advertisements
Similar presentations
Structured Query Language (SQL)
Advertisements

Copyright  Oracle Corporation, All rights reserved. 4 Aggregating Data Using Group Functions.
Restricting and sorting data 16 May May May Created By Pantharee Sawasdimongkol.
Subqueries 11. Objectives After completing this lesson, you should be able to do the following: Describe the types of problems that subqueries can solve.
1Eyad Alshareef Enhanced Guide to Oracle 10g Chapter 3: Using SQL Queries to Insert, Update, Delete, and View Data.
Copyright  Oracle Corporation, All rights reserved. 2 Restricting and Sorting Data.
Chapter 11 Group Functions
Multiple-Column Subqueries 12. Objectives After completing this lesson, you should be able to do the following: Write a multiple-column subquery Describe.
Multiple-Column Subqueries. Objectives After completing this lesson, you should be able to do the following: Write a Multiple-column subquery Describe.
Chapter 5 Recursion in SQL. 2 Example. Let Flights(Flight#, Source_Ctiy, Dest_City) be a relational schema DEN CHI SFO DAL NY UA 930 DL 900 UA 1400 UA.
Restricting and Sorting Data. Consider the table employee(employee_id,last_name,job_id, department_id ) assume that you want to display all the employees.
2 Copyright © 2004, Oracle. All rights reserved. Restricting and Sorting Data.
Databases Tutorial 2 Further Select Statements. Objectives for Week Data types Sort retrieved data Formatting output.
Logical Operators Operator AND OR NOT Meaning Returns TRUE if both component conditions are TRUE Returns TRUE if either component condition is TRUE Returns.
SELECT Advanced. Sorting data in a table The ORDER BY clause is used for sorting the data in either ascending or descending order depending on the condition.
Ceng 356-Lab2. Objectives After completing this lesson, you should be able to do the following: Limit the rows that are retrieved by a query Sort the.
Objectives After completing this lesson, you should be able to do the following: Define subqueries Describe the types of problems that the subqueries.
1 Copyright © Oracle Corporation, All rights reserved. Writing Basic SQL SELECT Statements.
Using SQL Queries to Insert, Update, Delete, and View Data Date Retrieval from a single table & Calculations © Abdou Illia MIS Spring 2015.
Chapter 3 Single-Table Queries
Copyright  Oracle Corporation, All rights reserved. 1 Writing Basic SQL Statements.
4-1 Copyright  Oracle Corporation, All rights reserved. Displaying Data from Multiple Tables.
Chapter 5 Advanced SQL. 2 Recursion in SQL Example. Let Flights(Flight#, Source_City, Dest_City) be a relational schema DEN CHI SFO DAL NY UA 930 DL 900.
Functions Oracle Labs 5 & 6. 2/3/2005Adapted from Introduction to Oracle: SQL and PL/SQL 2 SQL Functions Function arg n arg 2 arg 1. Input Resulting Value.
About the Presentations The presentations cover the objectives found in the opening of each chapter. All chapter objectives are listed in the beginning.
Restricting and Sorting Data. ◦ Limiting rows with:  The WHERE clause  The comparison conditions using =,
2 Copyright © Oracle Corporation, All rights reserved. Restricting and Sorting Data.
2 Copyright © 2004, Oracle. All rights reserved. Restricting and Sorting Data.
4 Copyright © 2006, Oracle. All rights reserved. Restricting and Sorting Data.
LECTURE 8.  Consider the table employee(employee_id,last_name,job_id, department_id )  assume that you want to display all the employees in department.
1 Single Table Queries. 2 Objectives  SELECT, WHERE  AND / OR / NOT conditions  Computed columns  LIKE, IN, BETWEEN operators  ORDER BY, GROUP BY,
Subqueries.
SELECT Statements Lecture Notes Sree Nilakanta Fall 2010 (rev)
Copyright س Oracle Corporation, All rights reserved. I Introduction.
Chapter 3 Selected Single-Row Functions and Advanced DML & DDL.
1 DBS201: Introduction to Structure Query Language (SQL) Lecture 1.
Advanced SELECT Queries CS 146. Review: Retrieving Data From a Single Table Syntax: Limitation: Retrieves "raw" data Note the default formats… SELECT.
2 第二讲 Restricting and Sorting Data. Objectives After completing this lesson, you should be able to do the following: Limit the rows retrieved by a query.
Copyright © 2004, Oracle. All rights reserved. Retrieving Data Using the SQL SELECT Statement Satrio Agung Wicaksono, S.Kom., M.Kom.
Copyright © 2004, Oracle. All rights reserved. Lecture 4: 1-Retrieving Data Using the SQL SELECT Statement 2-Restricting and Sorting Data Lecture 4: 1-Retrieving.
Queries SELECT [DISTINCT] FROM ( { }| ),... [WHERE ] [GROUP BY [HAVING ]] [ORDER BY [ ],...]
2 Copyright © 2004, Oracle. All rights reserved. Restricting and Sorting Data.
DATA RETRIEVAL WITH SQL Goal: To issue a database query using the SELECT command.
I-1 Copyright س Oracle Corporation, All rights reserved. Data Retrieval.
Displaying Data from Multiple Tables (SQL99 Syntax with examples)
An Introduction To SQL Part 2 (Special thanks to Geoff Leese)
1 Information Retrieval and Use (IRU) An Introduction To SQL Part 2.
Session 9 Accessing Data from a Database. RDBMS and Data Management/ Session 9/2 of 34 Session Objectives Describe the SELECT statement, its syntax and.
Copyright س Oracle Corporation, All rights reserved. I Introduction.
2 Copyright © 2009, Oracle. All rights reserved. Restricting and Sorting Data.
2-1 Limiting Rows Using a Selection “…retrieve all employees in department 10” EMP EMPNO ENAME JOB... DEPTNO 7839KINGPRESIDENT BLAKEMANAGER CLARKMANAGER.
ORDER BY clause in SELECT command: Normally, the result of the query will not be in ordered format. If we want to get the result of the query in specific.
A Guide to SQL, Eighth Edition Chapter Four Single-Table Queries.
1-1 Copyright  Oracle Corporation, All rights reserved. Logging In to SQL*Plus From Windows environment:From Windows environment: From command line:From.
Copyright  Oracle Corporation, All rights reserved. 2 Restricting and Sorting Data.
9/29/2005From Introduction to Oracle:SQL and PL/SQL, Oracle 1 Restricting and Sorting Data Kroenke, Chapter Two.
SQL: Structured Query Language It enables to create and operate on relational databases, which are sets of related information stored in tables. It is.
Limiting Selected Rows. 2-2 Objectives Sort row output using the ORDER BY clause. Sort row output using the ORDER BY clause. Enter search criteria using.
Communicating with a RDBMS Using SQL Database SQL> SELECT loc 2 FROM dept; SQL> SELECT loc 2 FROM dept; SQL statement is entered Statement is sent to database.
Chapter 5 Introduction to SQL.
Writing Basic SQL SELECT Statements
Basic select statement
Interacting with the Oracle Server
(SQL) Aggregating Data Using Group Functions
Aggregating Data Using Group Functions
Restricting and Sorting Data
Restricting and Sorting Data
MySQL SQL for MySQL (I) Salim Mail :
Lab 2: Retrieving Data from the Database
Presentation transcript:

1 ORACLE I 3 – SQL 1 Salim Phone: YM: talim_bansal

2 Summary Retrieving Data Using the SQL SELECT Statement Restricting and Sorting Data Using Single-Row Functions to Customize Output

3 SELECT COMMON PATTERN SELECT FROM WHERE AND/OR GROUP BY HAVING ORDER BY

4 Retrieving Data Using the SQL SELECT Statement Select All Columns Syntax: SELECT * FROM ; Sample: SELECT * FROM emp; Select Specific Columns Syntax: SELECT FROM ; Sample: SELECT empno, first_name, last_name FROM emp; Use Arithmetic Operators

5 Retrieving Data Using the SQL SELECT Statement Understand Operator Precedence Precedence defines the order that Oracle uses when evaluating different operators in the same expression. Every operator has a predefined precedence. Oracle evaluates operators with a higher precedence before it evaluates operators with a lower precedence. Operators with equal precedence will be evaluated from left to right Learn the DESCRIBE command to display the table structure Syntax: Desc Sample: Desc Dept;

6 Restricting and Sorting Data Write queries that contain a WHERE clause to limit the output retrieved Syntax: Select From Where ; Sample: Select empno From emp Where sal > 1000; Write queries that contain an ORDER BY clause sort the output of a SELECT statement (Ascending or Descending) Sample: Select * from emp Order by empno asc; Sample: Select * from emp Order by empno desc;

7 Restricting and Sorting Data List the comparison operators and logical operators that are used in a WHERE clause

8 Sample SELECT with WHERE using Comparison operators

9 Using Single-Row Functions to Customize Output Single Row Function VS Multiple Row Function Single-row function: "functions return a single result row for every row of a queried table or view. " Multiple row functions: "functions return a single result row based on groups of rows, rather than on single rows." an example using scott schema emp table: select empno, ename, to_char(sal, '9,999.99') from emp; --here to_char is a single row function select deptno, sum(sal) from emp group by deptno; --here sum() is a multiple row function.

10 Using Single-Row Functions to Customize Output Manipulate strings with character function Character functions that return character values return values of the same datatype as the input argument. The length of the value returned by the function is limited by the maximum length of the datatype returned. Source:

11 Using Single-Row Functions to Customize Output Manipulate strings with character function - Example

12 Using Single-Row Functions to Customize Output Number Function

13 Using Single-Row Functions to Customize Output Number Function - Example

14 Using Single-Row Functions to Customize Output Date Function

15 Practice & Question Answer