Single-row functions allow users to manipulate data within SQL queries. Common types include character, number, date, and conversion functions. Character functions modify strings, number functions perform calculations, date functions work with dates, and conversion functions change data types. Functions are useful for formatting output, performing calculations on individual rows, and conditional processing.
This document summarizes various SQL operators and built-in functions. It describes arithmetic, relational, logical, and string operators. It also discusses different types of built-in functions including character, numeric, date, aggregate/group, conversion, and general functions. Examples are provided to demonstrate how each operator and function works.
Attribute grammar is a type of context-free grammar that augments syntactic rules with semantic rules by adding attributes to non-terminals. Attributes have defined value domains and can pass information between nodes in a parse tree. There are two types of attributes: synthesized attributes derive their values from child nodes, while inherited attributes can take values from parent and sibling nodes. Attribute grammars can be categorized as S-attributed or L-attributed based on whether attributes only flow bottom-up or both bottom-up and top-down, respectively.
This document provides an introduction to finite automata. It defines key concepts like alphabets, strings, languages, and finite state machines. It also describes the different types of automata, specifically deterministic finite automata (DFAs) and nondeterministic finite automata (NFAs). DFAs have a single transition between states for each input, while NFAs can have multiple transitions. NFAs are generally easier to construct than DFAs. The next class will focus on deterministic finite automata in more detail.
This presentation shows slides to explain about the String functions in MySQL. It is suitable for students in IT studying DBMS, MySQL and Subject 065 Informatics Practice according to CBSE syllabus
SQL is a language for managing and manipulating databases. It includes languages for data definition (DDL), data manipulation (DML), data retrieval (DRL), transaction control (TCL), and data control (DCL). The document provides detailed syntax examples for creating tables, inserting data, selecting data using conditions, updating and deleting records, and managing transactions using commands like commit, rollback, and savepoints. It also covers altering tables and dropping or renaming database objects.
Consists of the explanations of the basics of SQL and commands of SQL.Helpful for II PU NCERT students and also degree studeents to understand some basic things.
This document discusses various control structures and loops in Oracle including simple loops, while loops, for loops, nested loops, and selective statements like if, if/else, if/elsif/else, and case. Loops allow iterating through a block of code until a condition is met. Control structures alter program flow. Nested loops allow looping within other loops. Selective statements perform actions conditionally based on evaluated conditions.
This document summarizes various SQL operators and built-in functions. It describes arithmetic, relational, logical, and string operators. It also discusses different types of built-in functions including character, numeric, date, aggregate/group, conversion, and general functions. Examples are provided to demonstrate how each operator and function works.
Attribute grammar is a type of context-free grammar that augments syntactic rules with semantic rules by adding attributes to non-terminals. Attributes have defined value domains and can pass information between nodes in a parse tree. There are two types of attributes: synthesized attributes derive their values from child nodes, while inherited attributes can take values from parent and sibling nodes. Attribute grammars can be categorized as S-attributed or L-attributed based on whether attributes only flow bottom-up or both bottom-up and top-down, respectively.
This document provides an introduction to finite automata. It defines key concepts like alphabets, strings, languages, and finite state machines. It also describes the different types of automata, specifically deterministic finite automata (DFAs) and nondeterministic finite automata (NFAs). DFAs have a single transition between states for each input, while NFAs can have multiple transitions. NFAs are generally easier to construct than DFAs. The next class will focus on deterministic finite automata in more detail.
This presentation shows slides to explain about the String functions in MySQL. It is suitable for students in IT studying DBMS, MySQL and Subject 065 Informatics Practice according to CBSE syllabus
SQL is a language for managing and manipulating databases. It includes languages for data definition (DDL), data manipulation (DML), data retrieval (DRL), transaction control (TCL), and data control (DCL). The document provides detailed syntax examples for creating tables, inserting data, selecting data using conditions, updating and deleting records, and managing transactions using commands like commit, rollback, and savepoints. It also covers altering tables and dropping or renaming database objects.
Consists of the explanations of the basics of SQL and commands of SQL.Helpful for II PU NCERT students and also degree studeents to understand some basic things.
This document discusses various control structures and loops in Oracle including simple loops, while loops, for loops, nested loops, and selective statements like if, if/else, if/elsif/else, and case. Loops allow iterating through a block of code until a condition is met. Control structures alter program flow. Nested loops allow looping within other loops. Selective statements perform actions conditionally based on evaluated conditions.
The document provides an introduction to automata theory and finite state automata (FSA). It defines an automaton as an abstract computing device or mathematical model used in computer science and computational linguistics. The reading discusses pioneers in automata theory like Alan Turing and his development of Turing machines. It then gives an overview of finite state automata, explaining concepts like states, transitions, alphabets, and using a example of building an FSA for a "sheeptalk" language to demonstrate these components.
This document provides an introduction and overview of PL/SQL. It discusses that PL/SQL is Oracle's procedural language extension for SQL and allows for transactions processing and block structuring. The document then covers various PL/SQL concepts like blocks, data types, control structures, variables and SQL operations within PL/SQL code.
This document discusses different types of keys used in databases. It defines keys as attributes that uniquely identify rows in tables. It then explains various key types including primary keys, candidate keys, super keys, alternate keys, unique keys, composite keys, foreign keys, natural keys and surrogate keys. For each key type, it provides examples from sample tables and discusses their properties and how they differ from each other. The document concludes that databases generally only contain primary, foreign, unique and surrogate keys, while other key types are conceptual, and that each table requires a unique key to reliably access and identify data.
The document discusses finite automata including nondeterministic finite automata (NFAs) and deterministic finite automata (DFAs). It provides examples of NFAs and DFAs that recognize particular strings, including strings containing certain substrings. It also gives examples of DFA state machines and discusses using finite automata to recognize regular languages.
This document provides an introduction to 8086 assembly language programming. It discusses machine code and assembly language, compilers and assemblers, general purpose registers, simple commands, number formats, jumps, labels, logical and shift instructions, and instructions that affect memory. The key points are that assembly language provides a lower-level programming interface than high-level languages, manages memory and registers directly, and uses mnemonics that are assembled into machine code.
This document discusses Noam Chomsky's hierarchy of formal languages. It introduces Chomsky's classification of formal languages from Type-0 to Type-3 based on the type of grammar that generates them. Type-0 languages are the most powerful, being generated by unrestricted grammars and equivalent to Turing machines. Type-3 languages are the simplest, being generated by regular grammars and equivalent to finite state automata. Examples are provided for each language type along with the computing models that recognize them, such as pushdown automata for context-free Type-2 languages.
Packages in PL/SQL group logically related types, variables, and subprograms. A package has a specification and body. The specification declares public objects available outside the package. The body defines private objects and code for methods in the specification. Public package elements can be called using package_name.element_name. Packages allow organizing program logic and controlling access.
The document introduces common data types in SQL such as char, varchar, int, numeric, and date. It describes how to create databases and tables using SQL statements like CREATE DATABASE, CREATE TABLE, INSERT INTO, and ALTER TABLE. It also covers SQL queries using SELECT, FROM, WHERE, ORDER BY, LIKE and other clauses to retrieve and filter data from one or more tables.
The document discusses different types of joins in database systems. It defines natural join, inner join, equi join, theta join, semi join, anti join, cross join, outer join including left, right and full outer joins, and self join. Examples are provided for each type of join to illustrate how they work.
The document provides an overview of Oracle for beginners, including the different editions of Oracle database, data types in Oracle such as character, numeric, date, and LOB data types. It also discusses how to create and alter Oracle tables, including adding, modifying and dropping columns, as well as renaming tables and columns. Primary keys in Oracle tables are also covered at a high level.
Automata theory studies abstract computing devices and the types of tasks they are capable of. Alan Turing pioneered this field in the 1930s by studying Turing machines. The theory examines questions like which tasks can and cannot be performed by different models of machines. It also considers the distinction between what is computable versus the complexity of computation. Common concepts include finite automata, formal languages, and the Chomsky hierarchy for classifying language types. Proofs in automata theory involve techniques like deduction, induction, contradiction, and establishing results by definition.
The document discusses various concepts related to finite automata. It begins by defining a finite automaton as a mathematical model of a system with discrete inputs and outputs that can be in a finite number of states. A finite automaton consists of a finite set of states and transitions between states based on input symbols. The document then discusses formal languages, the functions of a head pointer and finite control, the two main types of finite automata (DFA and NFA), ways to represent automata, definitions of languages and transitions, regular expressions and languages, two-way finite automata, epsilon closure, equivalence of NFAs and DFAs, Moore and Mealy machines, and applications of finite automata such as lexical analysis.
This document provides an overview of SQL commands and concepts. It begins by defining SQL and its uses for manipulating and retrieving data from relational databases. It then covers the main SQL commands: DDL for schema definition, DML for data manipulation, DCL for security, and TCL for transactions. Common data types are also defined. The document proceeds to explain SQL syntax and components like keywords, identifiers, and clauses. Specific SQL commands like CREATE TABLE, ALTER TABLE, DROP TABLE, INSERT, UPDATE, DELETE, SELECT are described along with examples. Logical and comparison operators are defined. The WHERE clause for filtering rows is explained.
PL/SQL is a combination of SQL along with the procedural features of programming languages.
It provides specific syntax for this purpose and supports exactly the same datatypes as SQL.
Functional dependency defines a relationship between attributes in a table where a set of attributes determine another attribute. There are different types of functional dependencies including trivial, non-trivial, multivalued, and transitive. An example given is a student table with attributes Stu_Id, Stu_Name, Stu_Age which has the functional dependency of Stu_Id->Stu_Name since the student ID uniquely identifies the student name.
This lecture slide contains:
1. Regular Languages
2. Regular Operations
3. Closure of regular languages
4. Regular expression
5. Precedence of regular operations
6. RE for different languages
7. RE to NFA conversion
8. DFA to GNFA to RE conversion
This document discusses procedures and functions in PL/SQL. It defines a procedure as a group of PL/SQL statements that can be called by name and does not need to return a value. A function is similar to a procedure but must return a single value. The document provides the syntax for creating procedures and functions, and examples of standalone and recursive procedures and functions. It explains how to call procedures and functions, and the differences between them, such as procedures not having a return value while functions do.
Applet Basics,
Applet Organization and Essential Elements,
The Applet Architecture,
A Complete Applet Skeleton,
Applet Initialization and Termination,
Requesting Repainting
The update() Method,
Using the Status Window
Passing parameters to Applets
The Applet Class
Event Handling The Delegation Event Model
Events,
Using the Delegation Event Model,
More Java Keywords.
Turing's thesis states that any computation that can be performed by a mechanical device can also be performed by a Turing machine. The document then discusses several variations of the standard Turing machine model, including machines with additional capabilities like staying in the same position or having multiple tapes. It proves that all of these machine variations have the same computational power as the standard Turing machine by demonstrating how to simulate one type of machine with another.
Single-row functions can manipulate data items, accept arguments and return one value, and act on each row returned. There are various types of single-row functions including character, number, date, and conversion functions. Character functions manipulate character strings, number functions perform calculations, and date functions modify date formats. Functions allow data to be formatted, calculated, and converted as needed for different queries and outputs.
Single-row functions in SQL allow users to manipulate data within individual rows and return a single result per row. This document describes different types of single-row functions including character, number, date, and conversion functions. It provides examples of how to use functions like UPPER, ROUND, ADD_MONTHS, TO_CHAR, and NVL to modify, format, and convert data as needed for SELECT statements. Nesting functions allows multiple operations to be performed sequentially on a data element.
The document provides an introduction to automata theory and finite state automata (FSA). It defines an automaton as an abstract computing device or mathematical model used in computer science and computational linguistics. The reading discusses pioneers in automata theory like Alan Turing and his development of Turing machines. It then gives an overview of finite state automata, explaining concepts like states, transitions, alphabets, and using a example of building an FSA for a "sheeptalk" language to demonstrate these components.
This document provides an introduction and overview of PL/SQL. It discusses that PL/SQL is Oracle's procedural language extension for SQL and allows for transactions processing and block structuring. The document then covers various PL/SQL concepts like blocks, data types, control structures, variables and SQL operations within PL/SQL code.
This document discusses different types of keys used in databases. It defines keys as attributes that uniquely identify rows in tables. It then explains various key types including primary keys, candidate keys, super keys, alternate keys, unique keys, composite keys, foreign keys, natural keys and surrogate keys. For each key type, it provides examples from sample tables and discusses their properties and how they differ from each other. The document concludes that databases generally only contain primary, foreign, unique and surrogate keys, while other key types are conceptual, and that each table requires a unique key to reliably access and identify data.
The document discusses finite automata including nondeterministic finite automata (NFAs) and deterministic finite automata (DFAs). It provides examples of NFAs and DFAs that recognize particular strings, including strings containing certain substrings. It also gives examples of DFA state machines and discusses using finite automata to recognize regular languages.
This document provides an introduction to 8086 assembly language programming. It discusses machine code and assembly language, compilers and assemblers, general purpose registers, simple commands, number formats, jumps, labels, logical and shift instructions, and instructions that affect memory. The key points are that assembly language provides a lower-level programming interface than high-level languages, manages memory and registers directly, and uses mnemonics that are assembled into machine code.
This document discusses Noam Chomsky's hierarchy of formal languages. It introduces Chomsky's classification of formal languages from Type-0 to Type-3 based on the type of grammar that generates them. Type-0 languages are the most powerful, being generated by unrestricted grammars and equivalent to Turing machines. Type-3 languages are the simplest, being generated by regular grammars and equivalent to finite state automata. Examples are provided for each language type along with the computing models that recognize them, such as pushdown automata for context-free Type-2 languages.
Packages in PL/SQL group logically related types, variables, and subprograms. A package has a specification and body. The specification declares public objects available outside the package. The body defines private objects and code for methods in the specification. Public package elements can be called using package_name.element_name. Packages allow organizing program logic and controlling access.
The document introduces common data types in SQL such as char, varchar, int, numeric, and date. It describes how to create databases and tables using SQL statements like CREATE DATABASE, CREATE TABLE, INSERT INTO, and ALTER TABLE. It also covers SQL queries using SELECT, FROM, WHERE, ORDER BY, LIKE and other clauses to retrieve and filter data from one or more tables.
The document discusses different types of joins in database systems. It defines natural join, inner join, equi join, theta join, semi join, anti join, cross join, outer join including left, right and full outer joins, and self join. Examples are provided for each type of join to illustrate how they work.
The document provides an overview of Oracle for beginners, including the different editions of Oracle database, data types in Oracle such as character, numeric, date, and LOB data types. It also discusses how to create and alter Oracle tables, including adding, modifying and dropping columns, as well as renaming tables and columns. Primary keys in Oracle tables are also covered at a high level.
Automata theory studies abstract computing devices and the types of tasks they are capable of. Alan Turing pioneered this field in the 1930s by studying Turing machines. The theory examines questions like which tasks can and cannot be performed by different models of machines. It also considers the distinction between what is computable versus the complexity of computation. Common concepts include finite automata, formal languages, and the Chomsky hierarchy for classifying language types. Proofs in automata theory involve techniques like deduction, induction, contradiction, and establishing results by definition.
The document discusses various concepts related to finite automata. It begins by defining a finite automaton as a mathematical model of a system with discrete inputs and outputs that can be in a finite number of states. A finite automaton consists of a finite set of states and transitions between states based on input symbols. The document then discusses formal languages, the functions of a head pointer and finite control, the two main types of finite automata (DFA and NFA), ways to represent automata, definitions of languages and transitions, regular expressions and languages, two-way finite automata, epsilon closure, equivalence of NFAs and DFAs, Moore and Mealy machines, and applications of finite automata such as lexical analysis.
This document provides an overview of SQL commands and concepts. It begins by defining SQL and its uses for manipulating and retrieving data from relational databases. It then covers the main SQL commands: DDL for schema definition, DML for data manipulation, DCL for security, and TCL for transactions. Common data types are also defined. The document proceeds to explain SQL syntax and components like keywords, identifiers, and clauses. Specific SQL commands like CREATE TABLE, ALTER TABLE, DROP TABLE, INSERT, UPDATE, DELETE, SELECT are described along with examples. Logical and comparison operators are defined. The WHERE clause for filtering rows is explained.
PL/SQL is a combination of SQL along with the procedural features of programming languages.
It provides specific syntax for this purpose and supports exactly the same datatypes as SQL.
Functional dependency defines a relationship between attributes in a table where a set of attributes determine another attribute. There are different types of functional dependencies including trivial, non-trivial, multivalued, and transitive. An example given is a student table with attributes Stu_Id, Stu_Name, Stu_Age which has the functional dependency of Stu_Id->Stu_Name since the student ID uniquely identifies the student name.
This lecture slide contains:
1. Regular Languages
2. Regular Operations
3. Closure of regular languages
4. Regular expression
5. Precedence of regular operations
6. RE for different languages
7. RE to NFA conversion
8. DFA to GNFA to RE conversion
This document discusses procedures and functions in PL/SQL. It defines a procedure as a group of PL/SQL statements that can be called by name and does not need to return a value. A function is similar to a procedure but must return a single value. The document provides the syntax for creating procedures and functions, and examples of standalone and recursive procedures and functions. It explains how to call procedures and functions, and the differences between them, such as procedures not having a return value while functions do.
Applet Basics,
Applet Organization and Essential Elements,
The Applet Architecture,
A Complete Applet Skeleton,
Applet Initialization and Termination,
Requesting Repainting
The update() Method,
Using the Status Window
Passing parameters to Applets
The Applet Class
Event Handling The Delegation Event Model
Events,
Using the Delegation Event Model,
More Java Keywords.
Turing's thesis states that any computation that can be performed by a mechanical device can also be performed by a Turing machine. The document then discusses several variations of the standard Turing machine model, including machines with additional capabilities like staying in the same position or having multiple tapes. It proves that all of these machine variations have the same computational power as the standard Turing machine by demonstrating how to simulate one type of machine with another.
Single-row functions can manipulate data items, accept arguments and return one value, and act on each row returned. There are various types of single-row functions including character, number, date, and conversion functions. Character functions manipulate character strings, number functions perform calculations, and date functions modify date formats. Functions allow data to be formatted, calculated, and converted as needed for different queries and outputs.
Single-row functions in SQL allow users to manipulate data within individual rows and return a single result per row. This document describes different types of single-row functions including character, number, date, and conversion functions. It provides examples of how to use functions like UPPER, ROUND, ADD_MONTHS, TO_CHAR, and NVL to modify, format, and convert data as needed for SELECT statements. Nesting functions allows multiple operations to be performed sequentially on a data element.
This document discusses various types of single-row functions in SQL including character, number, date, and conversion functions. It provides examples of using functions like UPPER, LOWER, ROUND, TRUNC, TO_CHAR, and NVL. Single-row functions manipulate or return a single value per row and may modify data types.
A function in PL/SQL is a named block that can take parameters and return a value. Functions have three sections: declaration, executable, and exception handling. They are created using the CREATE FUNCTION statement and can be single-row or multiple-row. Single-row functions return one result per row while multiple-row functions return one result per group of rows. Common functions include character, numeric, date, and conversion functions for manipulating values.
SQL Macros - Game Changing Feature for SQL Developers?Andrej Pashchenko
SQL Macros are functions that return SQL statements as text. When called in a SQL statement, the returned SQL text is parsed and optimized rather than executing the function at runtime. This avoids context switches to PL/SQL and allows the optimizer to see the full SQL. Table SQL macros can be called in the FROM clause and act like views or inline queries, except they allow parameters to make the views polymorphic. Scalar parameters in the returned SQL text are substituted like bind variables to make the macros more reusable and flexible.
This document describes various single-row functions in SQL that can manipulate or modify data. It discusses character, number, date, and conversion functions and provides examples of how to use functions like TO_CHAR, TO_NUMBER, ROUND, TRUNC, and DECODE in SELECT statements. Common uses of functions include performing calculations, formatting output, converting data types, and conditional processing of data. Nesting functions allows multiple operations to be applied sequentially.
The document discusses single-row functions in SQL. It describes that single-row functions manipulate or return one value per row based on arguments. Examples of different types of single-row functions are provided, including character, number, date, and general functions. Specific functions like UPPER, ROUND, SYSDATE, and NVL are described along with examples of how to use them in SQL queries. Nesting of functions is also covered.
This document discusses single-row functions in SQL. It describes various types of single-row functions including character, number, date, and conversion functions. Character functions manipulate character strings, number functions perform calculations on numbers, and date functions work with dates. Conversion functions explicitly convert between datatypes. Examples are provided to demonstrate how to use these functions in SELECT statements.
After completing this lesson, you should be able to do the following:
Describe various types of functions available in SQL
Use character, number, and date functions in SELECT statements
Describe the use of conversion functions
This document discusses single-row SQL functions. It defines single-row functions as functions that manipulate or return data for each row independently. The document categorizes common single-row functions such as character, number, date and conversion functions. It provides examples of how to use functions like TO_CHAR, TRUNC, and NVL. Nested functions and conditional expressions using DECODE are also introduced.
This document provides an overview of basic SQL statements and SQL*Plus commands. It describes how to select data from tables using the SELECT statement, perform calculations, and give columns aliases. It also summarizes how to describe table structures, edit SQL statements, and execute saved SQL files using SQL*Plus commands. The key capabilities of the SELECT statement are selection, projection, and joining data from multiple tables.
This document provides an overview of basic SQL statements and SQL*Plus commands. It covers capabilities of SELECT statements, executing a basic SELECT statement, writing SQL statements, selecting specific columns, using arithmetic expressions and operators, defining aliases and literals, eliminating duplicate rows, and interacting with SQL*Plus through commands like editing, saving, and running SQL statements.
This document provides an overview of basic SQL statements and SQL*Plus commands. It covers the capabilities of SELECT statements, including selecting all columns, specific columns, column aliases, arithmetic expressions, and literal strings. It also discusses null values, the concatenation operator, and eliminating duplicate rows with DISTINCT. Finally, it differentiates between SQL statements and SQL*Plus commands, describing how to log in to SQL*Plus, display table structure, edit SQL, and execute files of SQL statements.
The document discusses various lesser known facets of the MERGE statement in Oracle, including:
- ORA-30926 error which occurs when the source table has duplicate rows for the ON condition. This can cause the MERGE statement to execute multiple times.
- ORA-38104 error which prevents updating columns used in the ON clause. Various workarounds are presented such as using ROWID or subqueries.
- How write consistency and DML restarts apply to MERGE similar to other DML statements. The SET columns are tracked to prevent lost updates.
- Direct path insert cannot be used with MERGE but alternatives like INSERT with a subquery are presented.
- Parallel D
Understanding Query Optimization with ‘regular’ and ‘Exadata’ OracleGuatemala User Group
The document discusses query optimization with regular Oracle databases and Exadata databases. It explains what happens when a SQL statement is issued, including parsing, optimization, and execution. It describes what an execution plan is and how it can be generated and displayed. It discusses how operations can be offloaded to storage cells on Exadata and factors the optimizer considers for determining a good execution plan.
The document outlines activities in an object relational database course including creating object types and tables to store student data with object attributes, inserting records into the tables, and performing queries on the data including aggregation, ranking, and window functions. Object types are defined for people and students, and tables are created to store contact and student data using the object types.
This document provides an overview of single-row functions in SQL. It discusses different categories of single-row functions including character, number, date, and conversion functions. It provides examples of how to use functions like TO_CHAR, TO_NUMBER, ROUND, TRUNC, and NVL. It also covers conditional expressions using CASE and DECODE, and nesting multiple functions together.
SQL is a language used to interface with relational database systems. It was developed by IBM in the 1970s and is now an industry standard. SQL has three main sublanguages: DDL for defining database schemas, DML for manipulating data, and DCL for controlling access.
Some key points about SQL include:
- DDL commands like CREATE, ALTER, and DROP are used to define and modify database structures.
- DML commands like SELECT, INSERT, UPDATE, and DELETE are used to query and manipulate the data.
- DCL commands like COMMIT, ROLLBACK, GRANT and REVOKE control transactions and user privileges.
- SQL can be used
This document provides an overview of single-row functions in SQL. It describes various types of functions including character, number, date, conversion and general functions. It provides examples of how to use these functions in SELECT statements to manipulate and return data from individual rows. Key functions discussed include TO_CHAR, TO_NUMBER, TO_DATE, NVL, CASE, and DECODE. The document aims to describe how to use SQL functions to modify individual data items and output for groups of rows.
This document provides an overview of basic SQL statements including:
- Executing a basic SELECT statement to retrieve data from tables
- Using functions like SELECT, FROM, and DISTINCT to retrieve specific columns and eliminate duplicates
- Performing calculations on columns using arithmetic operators
- Renaming columns with aliases and concatenating columns
- Describing the structure of tables using the DESCRIBE command
The goal is to learn fundamental SQL skills like selecting, calculating, aliasing columns, and viewing table definitions.
Huffman codes are a technique for lossless data compression that assigns variable-length binary codes to characters, with more frequent characters having shorter codes. The algorithm builds a frequency table of characters then constructs a binary tree to determine optimal codes. Characters are assigned codes based on their path from the root, with left branches representing 0 and right 1. Both encoder and decoder use this tree to translate between binary codes and characters. The tree guarantees unique decoding and optimal compression.
SQLite only supports left outer joins. A left outer join returns all rows from the left table, along with matched rows from the right table. If there is no match, the right side will contain null values. The document demonstrates a left outer join between a COMPANY table and an ORDERS table to return name, amount, and date from orders matched to companies.
Group functions operate on sets of rows to give one result per group. Common group functions include COUNT, SUM, AVG, MIN, and MAX. The GROUP BY clause is used to divide rows into groups and the HAVING clause excludes groups based on a condition. Nesting group functions allows analyzing groups of groups, like finding the maximum of several averages.
This document discusses restricting and sorting data in SQL queries. It describes how to limit rows returned using a WHERE clause and comparison operators. It also explains how to sort rows using an ORDER BY clause, including sorting in ascending and descending order and by multiple columns. Logical operators, precedence rules, and NULL handling are also covered.
The document discusses quicksort and partition algorithms for sorting arrays. Quicksort works by recursively dividing an array into smaller sub-arrays by partitioning them based on a pivot value and sorting them. The partition algorithm divides an array into two partitions based on element values relative to the pivot. The performance of quicksort depends on how balanced the partitions are at each step.
SQL is a programming language used to communicate with and manipulate databases. It allows users to retrieve, insert, update and delete data from databases. Common SQL statements include JOINs, which combine data from two or more tables based on a common column. Some types of JOINs are INNER JOIN, which returns rows with matches in both tables; LEFT JOIN, which returns all rows from the left table; and FULL JOIN, which returns rows that match in either table. JOINs are often used with SELECT statements to query multiple tables at once.
This chapter discusses entity relationship (E-R) modeling and its purpose in database design. It covers the key components of E-R modeling including entities, attributes, relationships and how they are defined and refined. The chapter also explains conceptual, internal and external data models and how E-R diagrams represent the conceptual view through entities, attributes, and relationships. Generalization hierarchies and the iterative process for developing E-R diagrams are also summarized.
The relational database model chapter 2Nargis Ehsan
The document discusses the relational database model and its key concepts. It describes how the model focuses on logical representation of data using tables rather than physical storage. The main concepts covered are entities, attributes, tables, rows and columns, primary keys, foreign keys, and integrity rules. It also explains the common relational operators like select, project, join, union, intersect, difference, and product and provides examples of how they manipulate and combine table data. Finally, it discusses data dictionaries, system catalogs, and their role in metadata management.
This document discusses different types of communication networks within an organization:
1. Internal communication occurs within the organization, such as between a teacher and student.
2. External communication links the organization to outside entities, like between heads of two organizations.
3. Vertical communication flows up and down the hierarchy, including downward communication from managers to subordinates and upward communication with feedback from subordinates to managers.
4. Horizontal communication occurs between peers of equal rank in an organization.
5. Diagonal communication combines vertical and horizontal flows across different levels and departments when coordination is needed.
This document discusses different types of communication networks within an organization:
1. Internal communication occurs within the organization, such as between a teacher and student.
2. External communication links the organization to outside entities, like between heads of two organizations.
3. Vertical communication flows up and down the hierarchy, including downward communication from managers to subordinates and upward communication with feedback from subordinates to managers.
4. Horizontal communication occurs between peers of equal rank in an organization.
5. Diagonal communication combines vertical and horizontal flows across different levels and departments in an organization.
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdfMalak Abu Hammad
Discover how MongoDB Atlas and vector search technology can revolutionize your application's search capabilities. This comprehensive presentation covers:
* What is Vector Search?
* Importance and benefits of vector search
* Practical use cases across various industries
* Step-by-step implementation guide
* Live demos with code snippets
* Enhancing LLM capabilities with vector search
* Best practices and optimization strategies
Perfect for developers, AI enthusiasts, and tech leaders. Learn how to leverage MongoDB Atlas to deliver highly relevant, context-aware search results, transforming your data retrieval process. Stay ahead in tech innovation and maximize the potential of your applications.
#MongoDB #VectorSearch #AI #SemanticSearch #TechInnovation #DataScience #LLM #MachineLearning #SearchTechnology
Removing Uninteresting Bytes in Software FuzzingAftab Hussain
Imagine a world where software fuzzing, the process of mutating bytes in test seeds to uncover hidden and erroneous program behaviors, becomes faster and more effective. A lot depends on the initial seeds, which can significantly dictate the trajectory of a fuzzing campaign, particularly in terms of how long it takes to uncover interesting behaviour in your code. We introduce DIAR, a technique designed to speedup fuzzing campaigns by pinpointing and eliminating those uninteresting bytes in the seeds. Picture this: instead of wasting valuable resources on meaningless mutations in large, bloated seeds, DIAR removes the unnecessary bytes, streamlining the entire process.
In this work, we equipped AFL, a popular fuzzer, with DIAR and examined two critical Linux libraries -- Libxml's xmllint, a tool for parsing xml documents, and Binutil's readelf, an essential debugging and security analysis command-line tool used to display detailed information about ELF (Executable and Linkable Format). Our preliminary results show that AFL+DIAR does not only discover new paths more quickly but also achieves higher coverage overall. This work thus showcases how starting with lean and optimized seeds can lead to faster, more comprehensive fuzzing campaigns -- and DIAR helps you find such seeds.
- These are slides of the talk given at IEEE International Conference on Software Testing Verification and Validation Workshop, ICSTW 2022.
“An Outlook of the Ongoing and Future Relationship between Blockchain Technologies and Process-aware Information Systems.” Invited talk at the joint workshop on Blockchain for Information Systems (BC4IS) and Blockchain for Trusted Data Sharing (B4TDS), co-located with with the 36th International Conference on Advanced Information Systems Engineering (CAiSE), 3 June 2024, Limassol, Cyprus.
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...Neo4j
Leonard Jayamohan, Partner & Generative AI Lead, Deloitte
This keynote will reveal how Deloitte leverages Neo4j’s graph power for groundbreaking digital twin solutions, achieving a staggering 100x performance boost. Discover the essential role knowledge graphs play in successful generative AI implementations. Plus, get an exclusive look at an innovative Neo4j + Generative AI solution Deloitte is developing in-house.
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?Speck&Tech
ABSTRACT: A prima vista, un mattoncino Lego e la backdoor XZ potrebbero avere in comune il fatto di essere entrambi blocchi di costruzione, o dipendenze di progetti creativi e software. La realtà è che un mattoncino Lego e il caso della backdoor XZ hanno molto di più di tutto ciò in comune.
Partecipate alla presentazione per immergervi in una storia di interoperabilità, standard e formati aperti, per poi discutere del ruolo importante che i contributori hanno in una comunità open source sostenibile.
BIO: Sostenitrice del software libero e dei formati standard e aperti. È stata un membro attivo dei progetti Fedora e openSUSE e ha co-fondato l'Associazione LibreItalia dove è stata coinvolta in diversi eventi, migrazioni e formazione relativi a LibreOffice. In precedenza ha lavorato a migrazioni e corsi di formazione su LibreOffice per diverse amministrazioni pubbliche e privati. Da gennaio 2020 lavora in SUSE come Software Release Engineer per Uyuni e SUSE Manager e quando non segue la sua passione per i computer e per Geeko coltiva la sua curiosità per l'astronomia (da cui deriva il suo nickname deneb_alpha).
Sudheer Mechineni, Head of Application Frameworks, Standard Chartered Bank
Discover how Standard Chartered Bank harnessed the power of Neo4j to transform complex data access challenges into a dynamic, scalable graph database solution. This keynote will cover their journey from initial adoption to deploying a fully automated, enterprise-grade causal cluster, highlighting key strategies for modelling organisational changes and ensuring robust disaster recovery. Learn how these innovations have not only enhanced Standard Chartered Bank’s data infrastructure but also positioned them as pioneers in the banking sector’s adoption of graph technology.
For the full video of this presentation, please visit: https://www.edge-ai-vision.com/2024/06/building-and-scaling-ai-applications-with-the-nx-ai-manager-a-presentation-from-network-optix/
Robin van Emden, Senior Director of Data Science at Network Optix, presents the “Building and Scaling AI Applications with the Nx AI Manager,” tutorial at the May 2024 Embedded Vision Summit.
In this presentation, van Emden covers the basics of scaling edge AI solutions using the Nx tool kit. He emphasizes the process of developing AI models and deploying them globally. He also showcases the conversion of AI models and the creation of effective edge AI pipelines, with a focus on pre-processing, model conversion, selecting the appropriate inference engine for the target hardware and post-processing.
van Emden shows how Nx can simplify the developer’s life and facilitate a rapid transition from concept to production-ready applications.He provides valuable insights into developing scalable and efficient edge AI solutions, with a strong focus on practical implementation.
Communications Mining Series - Zero to Hero - Session 1DianaGray10
This session provides introduction to UiPath Communication Mining, importance and platform overview. You will acquire a good understand of the phases in Communication Mining as we go over the platform with you. Topics covered:
• Communication Mining Overview
• Why is it important?
• How can it help today’s business and the benefits
• Phases in Communication Mining
• Demo on Platform overview
• Q/A
Best 20 SEO Techniques To Improve Website Visibility In SERPPixlogix Infotech
Boost your website's visibility with proven SEO techniques! Our latest blog dives into essential strategies to enhance your online presence, increase traffic, and rank higher on search engines. From keyword optimization to quality content creation, learn how to make your site stand out in the crowded digital landscape. Discover actionable tips and expert insights to elevate your SEO game.
Infrastructure Challenges in Scaling RAG with Custom AI modelsZilliz
Building Retrieval-Augmented Generation (RAG) systems with open-source and custom AI models is a complex task. This talk explores the challenges in productionizing RAG systems, including retrieval performance, response synthesis, and evaluation. We’ll discuss how to leverage open-source models like text embeddings, language models, and custom fine-tuned models to enhance RAG performance. Additionally, we’ll cover how BentoML can help orchestrate and scale these AI components efficiently, ensuring seamless deployment and management of RAG systems in the cloud.
Dr. Sean Tan, Head of Data Science, Changi Airport Group
Discover how Changi Airport Group (CAG) leverages graph technologies and generative AI to revolutionize their search capabilities. This session delves into the unique search needs of CAG’s diverse passengers and customers, showcasing how graph data structures enhance the accuracy and relevance of AI-generated search results, mitigating the risk of “hallucinations” and improving the overall customer journey.
UiPath Test Automation using UiPath Test Suite series, part 5DianaGray10
Welcome to UiPath Test Automation using UiPath Test Suite series part 5. In this session, we will cover CI/CD with devops.
Topics covered:
CI/CD with in UiPath
End-to-end overview of CI/CD pipeline with Azure devops
Speaker:
Lyndsey Byblow, Test Suite Sales Engineer @ UiPath, Inc.
Driving Business Innovation: Latest Generative AI Advancements & Success StorySafe Software
Are you ready to revolutionize how you handle data? Join us for a webinar where we’ll bring you up to speed with the latest advancements in Generative AI technology and discover how leveraging FME with tools from giants like Google Gemini, Amazon, and Microsoft OpenAI can supercharge your workflow efficiency.
During the hour, we’ll take you through:
Guest Speaker Segment with Hannah Barrington: Dive into the world of dynamic real estate marketing with Hannah, the Marketing Manager at Workspace Group. Hear firsthand how their team generates engaging descriptions for thousands of office units by integrating diverse data sources—from PDF floorplans to web pages—using FME transformers, like OpenAIVisionConnector and AnthropicVisionConnector. This use case will show you how GenAI can streamline content creation for marketing across the board.
Ollama Use Case: Learn how Scenario Specialist Dmitri Bagh has utilized Ollama within FME to input data, create custom models, and enhance security protocols. This segment will include demos to illustrate the full capabilities of FME in AI-driven processes.
Custom AI Models: Discover how to leverage FME to build personalized AI models using your data. Whether it’s populating a model with local data for added security or integrating public AI tools, find out how FME facilitates a versatile and secure approach to AI.
We’ll wrap up with a live Q&A session where you can engage with our experts on your specific use cases, and learn more about optimizing your data workflows with AI.
This webinar is ideal for professionals seeking to harness the power of AI within their data management systems while ensuring high levels of customization and security. Whether you're a novice or an expert, gain actionable insights and strategies to elevate your data processes. Join us to see how FME and AI can revolutionize how you work with data!
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slackshyamraj55
Discover the seamless integration of RPA (Robotic Process Automation), COMPOSER, and APM with AWS IDP enhanced with Slack notifications. Explore how these technologies converge to streamline workflows, optimize performance, and ensure secure access, all while leveraging the power of AWS IDP and real-time communication via Slack notifications.
Unlocking Productivity: Leveraging the Potential of Copilot in Microsoft 365, a presentation by Christoforos Vlachos, Senior Solutions Manager – Modern Workplace, Uni Systems
2. Objectives
• After completing this lesson, you should
be able to do the following:
– Describe various types of functions available
in SQL
– Use character, number, and date functions in
SELECT statements
– Describe the use of conversion functions
4. Two Types of SQL Functions
FunctionsFunctions
Single-rowSingle-row
functionsfunctions
Multiple-rowMultiple-row
functionsfunctions
5. Single-Row Functions
– Manipulate data items
– Accept arguments and return one value
– Act on each row returned
– Return one result per row
– May modify the datatype
– Can be nested
function_name (column|expression, [arg1, arg2,...])function_name (column|expression, [arg1, arg2,...])
8. Function Result
Case Conversion Functions
• Convert case for character strings
LOWER('SQL Course')
UPPER('SQL Course')
INITCAP('SQL Course')
sql course
SQL COURSE
Sql Course
9. Using Case Conversion
Functions• Display the employee number, name, and
department number for employee Blake.
SQL> SELECT empno, ename, deptno
2 FROM emp
3 WHERE ename = 'blake';
no rows selectedno rows selected
SQL> SELECT empno, ename, deptno
2 FROM emp
3 WHERE ename = 'blake';
no rows selectedno rows selected
EMPNO ENAME DEPTNO
--------- ---------- ---------
7698 BLAKE 30
EMPNO ENAME DEPTNO
--------- ---------- ---------
7698 BLAKE 30
SQL> SELECT empno, ename, deptno
2 FROM emp
3 WHERE LOWER(ename) = 'blake';
11. Using the Character
Manipulation Functions
SQL> SELECT ename, CONCAT (ename, job), LENGTH(ename),
2 INSTR(ename, 'A')
3 FROM emp
4 WHERE SUBSTR(job,1,5) = 'SALES';
ENAME CONCAT(ENAME,JOB) LENGTH(ENAME) INSTR(ENAME,'A')
---------- ------------------- ------------- ----------------
MARTIN MARTINSALESMAN 6 2
ALLEN ALLENSALESMAN 5 1
TURNER TURNERSALESMAN 6 0
WARD WARDSALESMAN 4 2
12. Number Functions
– ROUND:Rounds value to specified decimal
ROUND(45.926, 2) 45.93
– TRUNC:Truncates value to specified decimal
TRUNC(45.926, 2) 45.92
– MOD: Returns remainder of division
MOD(1600, 300) 100
13. Using the ROUND Function
SQL> SELECT ROUND(45.923,2), ROUND(45.923,0),
2 ROUND(45.923,-1)
3 FROM DUAL;
ROUND(45.923,2) ROUND(45.923,0) ROUND(45.923,-1)
--------------- -------------- -----------------
45.92 46 50
14. SQL> SELECT TRUNC(45.923,2), TRUNC(45.923),
2 TRUNC(45.923,-1)
3 FROM DUAL;
TRUNC(45.923,2) TRUNC(45.923) TRUNC(45.923,-1)
--------------- ------------- ---------------
45.92 45 40
Using the TRUNC Function
15. Using the MOD Function
• Calculate the remainder of the ratio of
salary to commission for all employees
whose job title is salesman.
SQL> SELECT ename, sal, comm, MOD(sal, comm)
2 FROM emp
3 WHERE job = 'SALESMAN';
ENAME SAL COMM MOD(SAL,COMM)
---------- --------- --------- -------------
MARTIN 1250 1400 1250
ALLEN 1600 300 100
TURNER 1500 0 1500
WARD 1250 500 250
16. Working with Dates
– Oracle stores dates in an internal numeric
format: century, year, month, day, hours,
minutes, seconds.
– The default date format is DD-MON-YY.
– SYSDATE is a function returning date and
time.
– DUAL is a dummy table used to view
SYSDATE.
17. Arithmetic with Dates
– Add or subtract a number to or from a date
for a resultant date value.
– Subtract two dates to find the number of
days between those dates.
– Add hours to a date by dividing the number
of hours by 24.
18. Using Arithmetic Operators
with Dates
SQL> SELECT ename, (SYSDATE-hiredate)/7 WEEKS
2 FROM emp
3 WHERE deptno = 10;
ENAME WEEKS
---------- ---------
KING 830.93709
CLARK 853.93709
MILLER 821.36566
19. Date Functions
Number of months
between two dates
MONTHS_BETWEEN
ADD_MONTHS
NEXT_DAY
LAST_DAY
ROUND
TRUNC
Add calendar months to
date
Next day of the date
specified
Last day of the month
Round date
Truncate date
Function Description
23. TO_CHAR Function with Dates
• The format model:
– Must be enclosed in single quotation marks and is
case sensitive
– Can include any valid date format element
– Has an fm element to remove padded blanks or
suppress leading zeros
– Is separated from the date value by a comma
TO_CHAR(date, 'fmt')TO_CHAR(date, 'fmt')
24. YYYY
Elements of Date Format Model
YEAR
MM
MONTH
DY
DAY
Full year in numbers
Year spelled out
Two-digit value for month
Three-letter abbreviation of the
day of the week
Full name of the day
Full name of the month
25. Elements of Date Format Model
• Time elements format the time portion of
the date.
• Add character strings by enclosing them
in double quotation marks.
• Number suffixes spell out numbers.
HH24:MI:SS AM 15:45:32 PM
DD "of" MONTH 12 of OCTOBER
ddspth fourteenth
26. Using TO_CHAR Function
with Dates
SQL> SELECT ename,
2 TO_CHAR(hiredate, 'fmDD Month YYYY') HIREDATE
3 FROM emp;
ENAME HIREDATE
---------- -----------------
KING 17 November 1981
BLAKE 1 May 1981
CLARK 9 June 1981
JONES 2 April 1981
MARTIN 28 September 1981
ALLEN 20 February 1981
...
14 rows selected.
27. TO_CHAR Function with Numbers
• Use these formats with the TO_CHAR
function to display a number value as a
character:
TO_CHAR(number, 'fmt')TO_CHAR(number, 'fmt')
9
0
$
L
.
,
Represents a number
Forces a zero to be displayed
Places a floating dollar sign
Uses the floating local currency symbol
Prints a decimal point
Prints a thousand indicator
28. Using TO_CHAR Function
with Numbers
SQL> SELECT TO_CHAR(sal,'$99,999') SALARY
2 FROM emp
3 WHERE ename = 'SCOTT';
SALARY
--------
$3,000
29. TO_NUMBER and
TO_DATE Functions
– Convert a character string to a number
format using the TO_NUMBER function
TO_NUMBER(char[, 'fmt'])TO_NUMBER(char[, 'fmt'])
• Convert a character string to a date
format using the TO_DATE function
TO_DATE(char[, 'fmt'])TO_DATE(char[, 'fmt'])
30. NVL Function
• Converts null to an actual value
– Datatypes that can be used are date,
character, and number.
– Datatypes must match
• NVL(comm,0)
• NVL(hiredate,'01-JAN-97')
• NVL(job,'No Job Yet')
31. SQL> SELECT ename, sal, comm, (sal*12)+NVL(comm,0)
2 FROM emp;
Using the NVL Function
ENAME SAL COMM (SAL*12)+NVL(COMM,0)
---------- --------- --------- --------------------
KING 5000 60000
BLAKE 2850 34200
CLARK 2450 29400
JONES 2975 35700
MARTIN 1250 1400 16400
ALLEN 1600 300 19500
...
14 rows selected.
32. DECODE Function
• Facilitates conditional inquiries by doing
the work of a CASE or IF-THEN-ELSE
statement
DECODE(col/expression, search1, result1
[, search2, result2,...,]
[, default])
DECODE(col/expression, search1, result1
[, search2, result2,...,]
[, default])
33. Using the DECODE Function
SQL> SELECT job, sal,
2 DECODE(job, 'ANALYST', SAL*1.1,
3 'CLERK', SAL*1.15,
4 'MANAGER', SAL*1.20,
5 SAL)
6 REVISED_SALARY
7 FROM emp;
JOB SAL REVISED_SALARY
--------- --------- --------------
PRESIDENT 5000 5000
MANAGER 2850 3420
MANAGER 2450 2940
...
14 rows selected.
34. Using the DECODE Function
SQL> SELECT ename, sal,
2 DECODE(TRUNC(sal/1000, 0),
3 0, 0.00,
4 1, 0.09,
5 2, 0.20,
6 3, 0.30,
7 4, 0.40,
8 5, 0.42,
9 6, 0.44,
10 0.45) TAX_RATE
11 FROM emp
12 WHERE deptno = 30;
• Display the applicable tax rate for each
employee in department 30.
35. Nesting Functions
– Single-row functions can be nested to any level.
– Nested functions are evaluated from deepest
level to the least-deep level.
F3(F2(F1(col,arg1),arg2),arg3)
Step 1 = Result 1
Step 2 = Result 2
Step 3 = Result 3
36. Nesting Functions
SQL> SELECT ename,
2 NVL(TO_CHAR(mgr),'No Manager')
3 FROM emp
4 WHERE mgr IS NULL;
ENAME NVL(TO_CHAR(MGR),'NOMANAGER')
---------- -----------------------------
KING No Manager
37. Summary
• Use functions to do the following:
– Perform calculations on data
– Modify individual data items
– Manipulate output for groups of rows
– Alter date formats for display
– Convert column datatypes
38. Practice Overview
– Creating queries that require the use of numeric,
character, and date functions
– Using concatenation with functions
– Writing case-insensitive queries to test the usefulness
of character functions
– Performing calculations of years and months of service
for an employee
– Determining the review date for an employee
Lesson Aim
Functions make the basic query block more powerful and are used to manipulate data values. This is the first of two lessons that explore functions. You will focus on single-row character, number, and date functions, as well as those functions that convert data from one type to another—for example, character data to numeric.
SQL Functions
Functions are a very powerful feature of SQL and can be used to do the following:
Perform calculations on data
Modify individual data items
Manipulate output for groups of rows
Format dates and numbers for display
Convert column datatypes
SQL functions may accept arguments and always return a value.
Note: Most of the functions described in this lesson are specific to Oracle’s version of SQL.
Class Management Note
This lesson does not discuss all functions in great detail. Present the most common functions without a long explanation.
SQL Functions (continued)
There are two distinct types of functions:
Single-row functions
Multiple-row functions
Single-Row Functions
These functions operate on single rows only and return one result per row. There are different types of single-row functions. This lesson covers the following ones:
Character
Number
Date
Conversion
Multiple-Row Functions
These functions manipulate groups of rows to give one result per group of rows.
For more information, see Oracle Server SQL Reference, Release 8, for the complete list of available functions and syntax.
Single-Row Functions
Single-row functions are used to manipulate data items. They accept one or more arguments and return one value for each row returned by the query. An argument can be one of the following:
User-supplied constant
Variable value
Column name
Expression
Features of single-row functions:
Act on each row returned in the query
Return one result per row
May return a data value of a different type than that referenced
May expect one or more arguments
Can be used in SELECT, WHERE, and ORDER BY clauses; can be nested
In the syntax:
function_nameis the name of the function
columnis any named database column
expressionis any character string or calculated expression
arg1, arg2is any argument to be used by the function
Single-Row Functions (continued)
This lesson covers the following single-row functions:
Character functionsccept character input and can return both character and number values
Number functionsAccept numeric input and return numeric values
Date functionsOperate on values of the date datatype (All date functions return a value of date datatype except the MONTHS_BETWEEN function, which returns a number.)
Conversion functionsConvert a value from one datatype to another
General functions:
NVL function
DECODE function
Case Conversion Functions
LOWER, UPPER, and INITCAP are the three case conversion functions.
LOWERConverts mixed case or uppercase character string to lowercase
UPPERConverts mixed case or lowercase character string to uppercase
INITCAPConverts first letter of each word to uppercase and remaining letters to lowercase
EMPLOYEE DETAILS
-----------------------------------------
The job title for King is president
The job title for Blake is manager
The job title for Clark is manager
...
14 rows selected.
Case Conversion Functions (continued)
The slide example displays the employee number, name, and department number of employee BLAKE.
The WHERE clause of the first SQL statement specifies the employee name as 'blake.' Since all the data in the EMP table is stored in uppercase, the name 'blake' does not find a match in the EMP table and as a result no rows are selected.
The WHERE clause of the second SQL statement specifies that the employee name in the EMP table be converted to lowercase and then be compared to 'blake.' Since both the names are in lowercase now, a match is found and one row is selected. The WHERE clause can be rewritten in the following manner to produce the same result:
The name in the output appears as it was stored in the database. To display the name with the first letter capitalized, use the INITCAP function in the SELECT statement.
Character Manipulation Functions
CONCAT, SUBSTR, LENGTH, INSTR, and LPAD are the five character manipulation functions covered in this lesson.
CONCATJoins values together (You are limited to using two parameters with CONCAT.)
SUBSTRExtracts a string of determined length
LENGTHShows the length of a string as a numeric value
INSTRFinds numeric position of a named character
LPADPads the character value right-justified
Note: RPAD character manipulation function pads the character value left-justified
Class Management Note
Be sure to point out RPAD to the students, as this function will needed in a practice exercise.
Also, LTRIM and RTRIM are replaced by one function, TRIM, in Oracle8i.
Character Manipulation Functions (continued)
The slide example displays employee name and job joined together, length of the employee name, and the numeric position of the letter A in the employee name, for all employees who are in sales.
Example
Modify the SQL statement on the slide to display the data for those employees whose names end with an N.
Number Functions
Number functions accept numeric input and return numeric values. This section describes some of the number functions.
Note: This list is a subset of the available number functions.
For more information, seeOracle Server SQL Reference, Release 8, “Number Functions.”
ROUND Function
The ROUND function rounds the column, expression, or value to n decimal places. If the second argument is 0 or is missing, the value is rounded to zero decimal places. If the second argument is 2, the value is rounded to two decimal places. Conversely, if the second argument is -2, the value is rounded to two decimal places to the left.
The ROUND function can also be used with date functions. You will see examples later in this lesson.
The DUAL is a dummy table. More about this will be covered later.
TRUNC Function
The TRUNC function truncates the column, expression, or value to n decimal places.
The TRUNC function works with arguments similar to those of the ROUND function. If the second argument is 0 or is missing, the value is truncated to zero decimal places. If the second argument is 2, the value is truncated to two decimal places. Conversely, if the second argument is -2, the value is truncated to two decimal places to the left.
Like the ROUND function, the TRUNC function can be used with date functions.
MOD Function
The MOD function finds the remainder of value1 divided by value2. The slide example calculates the remainder of the ratio of salary to commission for all employees whose job title is salesman.
Oracle Date Format
Oracle stores dates in an internal numeric format, representing the century, year, month, day, hours, minutes, and seconds.
The default display and input format for any date is DD-MON-YY. Valid Oracle dates are between January 1, 4712 B.C., and December 31, 9999 A.D.
SYSDATE
SYSDATE is a date function that returns the current date and time. You can use SYSDATE just as you would use any other column name. For example, you can display the current date by selecting SYSDATE from a table. It is customary to select SYSDATE from a dummy table called DUAL.
DUAL
The DUAL table is owned by the user SYS and can be accessed by all users. It contains one column, DUMMY, and one row with the value X. The DUAL table is useful when you want to return a value once only—for instance, the value of a constant, pseudocolumn, or expression that is not derived from a table with user data.
Example
Display the current date using the DUAL table.
Arithmetic with Dates
Since the database stores dates as numbers, you can perform calculations using arithmetic operators such as addition and subtraction. You can add and subtract number constants as well as dates.
You can perform the following operations:
Arithmetic with Dates (continued)
The example on the slide displays the name and the number of weeks employed for all employees in department 10. It subtracts the current date (SYSDATE) from the date on which the employee was hired and divides the result by 7 to calculate the number of weeks that a worker has been employed.
Note: SYSDATE is a SQL function that returns the current date and time. Your results may differ from the example.
Class Management Note
If an older date is subtracted from a more current date, the difference is a negative number.
Date Functions
Date functions operate on Oracle dates. All date functions return a value of DATE datatype except MONTHS_BETWEEN, which returns a numeric value.
MONTHS_BETWEEN(date1, date2)Finds the number of months between date1 and date2. The result can be positive or negative. If date1 is later than date2, the result is positive; if date1 is earlier than date2, the result is negative. The noninteger part of the result represents a portion of the month.
ADD_MONTHS(date, n)Adds n number of calendar months to date. The value of n must be an integer and can be negative.
NEXT_DAY(date, 'char')Finds the date of the next specified day of the week ('char') following date. The value of char may be a number representing a day or a character string.
LAST_DAY(date)Finds the date of the last day of the month that contains date.
ROUND(date[,'fmt'])Returns date rounded to the unit specified by the format model fmt. If the format model fmt is omitted, date is rounded to the nearest day.
TRUNC(date[, 'fmt'])Returns date with the time portion of the day truncated to the unit specified by the format model fmt. If the format model fmt is omitted, date is truncated to the nearest day.
This list is a subset of the available date functions. The format models are covered later in this lesson. Examples of format models are month and year.
Date Functions (continued)
For all employees employed for fewer than 200 months, display the employee number, hire date, number of months employed, six-month review date, first Friday after hire date, and last day of the month when hired.
SQL> SELECT empno, hiredate,
2MONTHS_BETWEEN(SYSDATE, hiredate) TENURE,
3ADD_MONTHS(hiredate, 6) REVIEW,
4NEXT_DAY(hiredate, 'FRIDAY'), LAST_DAY(hiredate)
5 FROMemp
6 WHEREMONTHS_BETWEEN (SYSDATE, hiredate)<200;
Date Functions (continued)
The ROUND and TRUNC functions can be used for number and date values. When used with dates, these functions round or truncate to the specified format model. Therefore, you can round dates to the nearest year or month.
Example
Compare the hire dates for all employees who started in 1982. Display the employee number, hire date, and month started using the ROUND and TRUNC functions.
SQL> SELECTempno, hiredate,
2ROUND(hiredate, 'MONTH'), TRUNC(hiredate, 'MONTH')
3 FROMemp
4 WHEREhiredate like '%82';
EMPNO HIREDATE ROUND(HIR TRUNC(HIR
--------- --------- --------- ---------
7788 09-DEC-82 01-DEC-82 01-DEC-82
7934 23-JAN-82 01-FEB-82 01-JAN-82
Explicit Datatype Conversion
SQL provides three functions to convert a value from one datatype to another.
Note: This list is a subset of the available conversion functions.
For more information, see Oracle Server SQL Reference, Release 8, “Conversion Functions.”
Class Management Note
An additional conversion function is CHR(number) which returns the character having the binary equivalent of number as a VARCHAR2 value in the database character set.
Displaying a Date in a Specific Format
Previously, all Oracle date values were displayed in the DD-MON-YY format. The TO_CHAR function allows you to convert a date from this default format to one specified by you.
Guidelines
The format model must be enclosed in single quotation marks and is case sensitive.
The format model can include any valid date format element. Be sure to separate the date value from the format model by a comma.
The names of days and months in the output are automatically padded with blanks.
To remove padded blanks or to suppress leading zeros, use the fill mode fm element.
You can resize the display width of the resulting character field with the SQL*Plus COLUMN command.
The resultant column width is 80 characters by default.
Class Management Note for Page 27
Be sure to point out the format token ‘D’ as the students will need it for Practice exercise #10.
Sample Elements of Valid Date Formats
Time Formats
Use the formats listed in the following tables to display time information and literals and to change numerals to spelled numbers.
Other Formats
Specifying Suffixes to Influence Number Display
TO_CHAR Function with Dates
The SQL statement on the slide displays the name and hire dates for all the employees. The hire date appears as 17 November 1981.
Example
Modify the slide example to display the dates in a format that appears as Seventh of February 1981 08:00:00 AM.
Notice that the month follows the format model specified (INITCAP).
TO_CHAR Function with Numbers
When working with number values such as character strings, you should convert those numbers to the character datatype using the TO_CHAR function, which translates a value of NUMBER datatype to VARCHAR2 datatype. This technique is especially useful with concatenation.
Number Format Elements
If you are converting a number to character datatype, you can use the following elements:
Guidelines
The Oracle Server displays a string of pound signs (#) in place of a whole number whose digits exceed the number of digits provided in the format model.
The Oracle Server rounds the stored decimal value to the number of decimal spaces provided in the format model.
TO_NUMBER and TO_DATE Functions
You may want to convert a character string to either a number or a date. To accomplish this task, you use the TO_NUMBER or TO_DATE functions. The format model you choose will be based on the previously demonstrated format elements.
Example
Display the names and hire dates of all the employees who joined on February 22, 1981.
The NVL Function
To convert a null value to an actual value, use the NVL function.
Syntax
NVL (expr1, expr2)
where:expr1 is the source value or expression that may contain null
expr2 is the target value for converting null
You can use the NVL function to convert any datatype, but the return value is always the same as the datatype of expr1.
NVL Conversions for Various Datatypes
NVL Function
To calculate the annual compensation of all employees, you need to multiply the monthly salary by 12 and then add the commission to it.
Notice that the annual compensation is calculated only for those employees who earn a commission. If any column value in an expression is null, the result is null. To calculate values for all employees, you must convert the null value to a number before applying the arithmetic operator. In the example on the slide, the NVL function to is used to convert null values to zero.
The DECODE Function
The DECODE function decodes an expression in a way similar to the IF-THEN-ELSE logic used in various languages. The DECODE function decodes expression after comparing it to each search value. If the expression is the same as search, result is returned.
If the default value is omitted, a null value is returned where a search value does not match any of the result values.
Using the DECODE Function
In the SQL statement above, the value of JOB is decoded. If JOB is ANALYST, the salary increase is 10%; if JOB is CLERK, the salary increase is 15%; if JOB is MANAGER, the salary increase is 20%. For all other job roles, there is no increase in salary.
The same statement can be written as an IF-THEN-ELSE statement:
Example
The slide shows another example using the DECODE function. In this example, we determine the tax rate for each employee in department 30 based upon the monthly salary. The output is below.
Monthly Salary RangeRate
$ 0.00 - 999.99 0%
$1,000.00 - 1,999.99 9%
$2,000.00 - 2,999.9920%
$3,000.00 - 3,999.9930%
$4,000.00 - 4,999.9940%
$5,000.00 - 5,999.9942%
$6,000.00 - 6,999.9944%
$7,000.00 or greater45%
ENAME SAL TAX_RATE
---------- --------- ---------
BLAKE 2850 .2
MARTIN 1250 .09
ALLEN 1600 .09
TURNER 1500 .09
...
6 rows selected.
Nesting Functions
Single-row functions can be nested to any depth. Nested functions are evaluated from the innermost level to the outermost level. Some examples follow to show you the flexibility of these functions.
Class Management Note (for Page 3-39)
Demo: l3nest.sql
Purpose: To illustrate nesting of several single row functions.
Nesting Functions (continued)
The slide example displays the head of the company, who has no manager. The evaluation of the SQL statement involves two steps:
1. Evaluate the inner function to convert a number value to a character string.
Result1 = TO_CHAR(mgr)
2. Evaluate the outer function to replace the null value with a text string.
NVL(Result1, 'No Manager')
The entire expression becomes the column heading because no column alias was given.
Example
Display the date of the next Friday that is six months from the hire date. The resultant date should appear as Friday, March 12th, 1982. Order the results by hire date.
Single-Row Functions
Single-row functions can be nested to any level. Single-row functions can manipulate the following:
Character data: LOWER, UPPER, INITCAP, CONCAT, SUBSTR, INSTR, LENGTH
Number data: ROUND, TRUNC, MOD
Date data: MONTHS_BETWEEN, ADD_MONTHS, NEXT_DAY, LAST_DAY, ROUND, TRUNC
Date values can also use arithmetic operators.
Conversion functions can convert character, date, and numeric values: TO_CHAR, TO_DATE, TO_NUMBER
SYSDATE and DUAL
SYSDATE is a date function that returns the current date and time. It is customary to select SYSDATE from a dummy table called DUAL.
Practice Overview
This practice is designed to give you a variety of exercises using different functions available for character, number, and date data types.
Remember that for nested functions, the results are evaluated from the innermost function to the outermost function.
Class Management Note
Practice exercise #6: Be sure to tell the students that their results may differ from the one provided, as SYSDATE is used in the exercise.
Instructor hint for practice exercise #10: The ORDER BY clause in the solution sorts on TO_CHAR(hiredate-1, ‘d’). The format element ‘d’ returns a ‘1’ for Sunday, ‘2’ for Monday, and so forth. The expression ‘hiredate-1’ effectively “shifts” each hiredate to the previous day, so that an employee hired on a Monday appears to have been hired on Sunday. The TO_CHAR function will return a ‘1’ for that employee and the result set will be sorted beginning with those employees hired on Monday.