SQL 101 3rd Session.

Slides:



Advertisements
Similar presentations
Copyright  Oracle Corporation, All rights reserved. 2 Single-Row Functions.
Advertisements

2009 Spring Errors & Source of Errors SpringBIL108E Errors in Computing Several causes for malfunction in computer systems. –Hardware fails –Critical.
Objectives After completing this lesson, you should be able to do the following: Describe various types of conversion functions that are available in.
Copyright © 2007, Oracle. All rights reserved Using Single-Row Functions to Customize Output Modified: October 21, 2014.
Maths & Trig, Statistical functions. ABS Returns the absolute value of a number The absolute value of a number is the number without its sign Syntax ◦
 A function is a type of formula whose result is one of two things: either a transformation or information.  Syntax Symbols SYMBOLUSAGE []Square brackets.
CS 3630 Database Design and Implementation. SQL Query Clause Select and From Select * From booking; select hotel_no, guest_no, room_no from booking; select.
Databases Lab 5 Further Select Statements. Functions in SQL There are many types of functions provided. The ones that are used most are: –Date and Time.
Advanced Topics: Business Intelligence Features
Introduction to Oracle9i: SQL1 Selected Single-Row Functions.
Using Single-Row Functions to Customize Output
Lecture 6 29/1/15. Number functions Number functions take numbers as input, change them, and output the results as numbers. 2.
Ch. 3 Single-Row Functions Important Legal Notice:  Materials on this lecture are from a book titled “Oracle Education” by Kochhar, Gravina, and Nathan.
Single-Row Functions. SQL Functions Functions are a very powerful feature of SQL and can be used to do the following: Perform calculations on data Modify.
3-1 Copyright  Oracle Corporation, All rights reserved. SQL Functions FunctionInput arg 1 arg 2 arg n Function performs action OutputResultvalue.
Oracle FUNCTIONS. Comment ScreenShot (in 10g) General Example of null Foreign Key: create table deptcs( deptno NUMBER(4) primary key, hiredate DATE,
Number Functions. 2 home back first prev next last Review single-row character functions –character case-manipulation functions  LOWER, UPPER, INITCAP.
3 Copyright © Oracle Corporation, All rights reserved. Single-Row Functions.
2-1 Copyright © Oracle Corporation, All rights reserved. Character Strings and Dates Character strings and date values are enclosed in single quotation.
Chapter 10 Selected Single-Row Functions Oracle 10g: SQL.
Chapter 5 Selected Single-Row Functions. Chapter Objectives  Use the UPPER, LOWER, and INITCAP functions to change the case of field values and character.
Single-Row Functions. Two Types of SQL Functions There are two distinct types of functions: Single-row functions Multiple-row functions Single-Row Functions.
SINGLE-ROW FUNCTIONS Lecture 9. SQL Functions Functions are very powerful feature of SQL and can be used to do the following:  Perform a calculation.
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.
3 Copyright © 2004, Oracle. All rights reserved. Using Single-Row Functions to Customize Output.
Single – Row Functions. Objectives After completing this lesson, you should be able to do the following:  Describe various types of functions available.
Single Row Functions Week 2. Objectives –Describe types of single row functions in SQL –Describe and use character, number, date, general and conversion.
Oracle 11g: SQL Chapter 10 Selected Single-Row Functions.
SQL Oracle PL/SQL. Select SELECT column1, column2,...columnN FROM table_name WHERE condition; SELECT column1, column2,...columnN FROM table_name WHERE.
SQL SELECT QUERIES CS 260 Database Systems. Overview  Introduction to SQL  Single-table select queries  Using the DBMS to manipulate data output 
SINGLE ROW FUNCTIONS 1. CHARACTER MANIPULATION Prof. Carmen Popescu Oracle Academy Lead Adjunct.
Chapter 3 Selected Single-Row Functions and Advanced DML & DDL.
6 Copyright © 2006, Oracle. All rights reserved. Using Single-Row Functions to Customize Output.
EXPRESSION Transformation. Introduction ►Transformations help to transform the source data according to the requirements of target system and it ensures.
IFS Intro to Data Management Chapter 5 Getting More Than Simple Columns.
Single Row Functions. Objectives –Use character, number, and date functions –Use conversion functions –Describe types of single row functions in SQL.
1 Creating and Maintaining Database Objects Part 1 Database Systems.
Copyright  Oracle Corporation, All rights reserved. 3 Single-Row Functions.
3 Copyright © 2009, Oracle. All rights reserved. Using Single-Row Functions to Customize Output.
3 Copyright © Oracle Corporation, All rights reserved. Single-Row Functions.
3 Copyright © Oracle Corporation, All rights reserved. Single-Row Functions.
3 第三讲 Single-Row Functions. Objectives After completing this lesson, you should be able to do the following: Describe various types of functions available.
6 Copyright © Oracle Corporation, All rights reserved. Subqueries.
SQL Functions. SQL functions are built into Oracle Database and are available for use in various appropriate SQL statements. These functions are use full.
Built-in SQL Functions. 2 Type of Functions Character Functions returning character values returning numeric values Numeric Functions Date Functions Conversion.
Using Single-Row Functions to Customize Output
3 Copyright © 2007, Oracle. All rights reserved. Substitution Variables ra Oly l&On nase lce Int erU.
4/2/16. Ltrim() is used to remove leading occurrences of characters. If we don’t specify a character, Oracle will remove leading spaces. For example Running.
Gollis University Faculty of Computer Engineering Chapter Five: Retrieval, Functions Instructor: Mukhtar M Ali “Hakaale” BCS.
3 Copyright © 2009, Oracle. All rights reserved. Using Single-Row Functions to Customize Output.
Defining a Column Alias
Copyright  Oracle Corporation, All rights reserved. 3 Single-Row Functions.
Single Row Functions Part I Week 2. Objectives –Describe types of single row functions in SQL –Describe and use character, number and date SQL functions.
Floating Point Numbers
Introduction to Numerical Analysis I
Machine arithmetic and associated errors Introduction to error analysis Class II.
CS 3630 Database Design and Implementation
Open Source Server Side Scripting MySQL Functions
Chapter 10 Selected Single-Row Functions Oracle 10g: SQL
Number Systems and Binary Arithmetic
Restricting and Sorting Data
Chapter Nine Data Manipulation Language (DML) Functions
CS 3630 Database Design and Implementation
Using Single-Row Functions to Customize Output
Approximations and Round-Off Errors Chapter 3
دوال حرفية دوال رقميه دوال تاريخ دوال تحويل
SQL 101 2nd Session.
Single-Row Functions Lecture 9.
Index Note: A bolded number or letter refers to an entire lesson or appendix. A Adding Data Through a View ADD_MONTHS Function 03-22, 03-23,
Lecture 5 SQL FUNCTIONS.
Presentation transcript:

SQL 101 3rd Session

Functions: - Character functions - Number functions  today - Single Row functions

Character Functions: LOWER UPPER INITCAP LPAD RPAD LTRIM RTRIM TRIM SUBSTR INSTR LENGTH in WHERE & GROUP BY clauses Nested functions Concatenation REPLACE TRANSLATE SOUNDEX

Number Functions: ABS SIGN ROUND TRUNC FLOOR CEIL MOD REMAINDER Floating point numbers Arithmetic operators

Single-Row Functions: NVL COALESCE NVL2 LNNVL NULLIF NANVL DECODE Searched CASE Simple CASE

Number functions.... ABS(value) SIGN(value) ROUND(value [, precision]) TRUNC(value [, precision]) SELECT 'The absolute value of -29 is '||ABS(-29) FROM dual; SELECT -14, SIGN(-14), SIGN(14), SIGN(0), ABS(-14) SELECT 222.34501, ROUND(222.34566, 2), TRUNC(222.34566, 1) FROM dual; SELECT 222.34501, ROUND(222.34566, -2), TRUNC(222.34566, -1)

Round 249.34566 to the number 250 Round 249.34566 to the number 249.35 Round 249.34566 to ZERO Truncate 249.34566 to 200

Number functions.... FLOOR(value) CEIL(value) MOD(value, divisor) REMAINDER(value, divisor) Floating Point Numbers SELECT FLOOR(22.53), CEIL(22.49), TRUNC(22.5), ROUND(22.5) FROM dual; SELECT MOD(23,8) FROM dual; SELECT MOD(23,8), REMAINDER(23,8) FROM dual; Ref: http://docs.oracle.com/cd/E11882_01/server.112/e25789/tablecls.htm#CNCPT1834 Floating-Point Numbers Oracle Database provides two numeric data types exclusively for floating-point numbers: BINARY_FLOAT and BINARY_DOUBLE. These types support all of the basic functionality provided by the NUMBER data type. However, while NUMBER uses decimal precision, BINARY_FLOAT and BINARY_DOUBLE use binary precision, which enables faster arithmetic calculations and usually reduces storage requirements. BINARY_FLOAT and BINARY_DOUBLE are approximate numeric data types. They store approximate representations of decimal values, rather than exact representations. For example, the value 0.1 cannot be exactly represented by either BINARY_DOUBLE or BINARY_FLOAT. They are frequently used for scientific computations. Their behavior is similar to the data types FLOAT and DOUBLE in Java and XMLSchema.

+ - * / Number functions.... SELECT DISTINCT(cost), cost + 10, + - * / SELECT DISTINCT(cost), cost + 10, cost – 10, cost * 10, cost / 10 FROM course; SELECT DISTINCT cost + (cost * .10)