The document discusses various SQL clauses and operators for restricting, sorting, and filtering data retrieved from database tables. It covers the WHERE clause for filtering rows, comparison operators like = and BETWEEN, logical operators like AND and OR, NULL handling, pattern matching with LIKE, and sorting order with ORDER BY. Examples are provided to demonstrate how each technique can be used in a SELECT statement to selectively retrieve only the needed data from database tables.
This document discusses restricting and sorting data in SQL queries. It covers limiting rows using the WHERE clause with various operators like comparison, logical, BETWEEN, IN, LIKE and IS NULL. It also covers sorting result rows using the ORDER BY clause, including sorting in ascending and descending order and by multiple columns. The overall goal is to select specific data rows and control the order of rows displayed in the results.
This document discusses how to restrict and sort data retrieved by SQL queries. It covers limiting rows using the WHERE clause and comparison operators, and sorting rows using the ORDER BY clause. Examples are provided for each clause and operator to filter rows by conditions and sort the output in ascending or descending order on one or multiple columns. Parentheses can be used to override the default order of operation precedence.
Group functions operate on sets of rows to give one result per group. Some key points covered in the document include:
1. Group functions like AVG, COUNT, MAX, MIN, SUM allow aggregating data across rows grouped by columns like department.
2. The GROUP BY clause is used to divide rows into groups and column(s) in the SELECT that are not aggregate functions must be in the GROUP BY.
3. The HAVING clause is used to filter groups based on conditions with aggregate functions and comes after GROUP BY.
Subqueries allow queries to be nested within other queries. They can return either single rows or multiple rows. Single-row subqueries use comparison operators like = or >, while multiple-row subqueries use operators like IN, ANY, or ALL. Subqueries execute first before the outer or main query uses the results. This allows the main query to filter or compare based on unknown values from the subquery.
This document discusses how to limit and sort data retrieved from a database table using SQL queries. It covers using the WHERE clause to restrict rows by conditions, comparison operators like = and BETWEEN, logical operators like AND and OR, and the ORDER BY clause to sort rows in ascending or descending order based on one or more columns. Examples are provided for each technique.
This document discusses views in Oracle databases. It defines a view as a virtual table derived from one or more underlying base tables or other views. The document covers how to create simple and complex views, modify view definitions, perform DML operations on views, and remove views. Key points include that views allow restricting access, simplifying queries, and presenting different perspectives of the same data without affecting the base tables.
This document discusses techniques for joining data from multiple database tables. It covers equijoins to retrieve matching records between tables, non-equijoins to retrieve records with non-equal conditions, outer joins to include non-matching records, and self joins to join a table to itself. Examples are provided to demonstrate how to write SQL statements to perform each type of join and include additional conditions.
This document discusses how to limit and sort data retrieved by SQL queries. It covers using the WHERE clause to restrict rows selected based on conditions, comparison operators like = and BETWEEN, logical operators like AND and OR, and the ORDER BY clause to sort rows in ascending or descending order. Examples are provided for each concept to demonstrate proper SQL syntax. The overall goal is to teach how to selectively retrieve only the relevant data needed from a database table.
This document discusses restricting and sorting data in SQL queries. It covers limiting rows using the WHERE clause with various operators like comparison, logical, BETWEEN, IN, LIKE and IS NULL. It also covers sorting result rows using the ORDER BY clause, including sorting in ascending and descending order and by multiple columns. The overall goal is to select specific data rows and control the order of rows displayed in the results.
This document discusses how to restrict and sort data retrieved by SQL queries. It covers limiting rows using the WHERE clause and comparison operators, and sorting rows using the ORDER BY clause. Examples are provided for each clause and operator to filter rows by conditions and sort the output in ascending or descending order on one or multiple columns. Parentheses can be used to override the default order of operation precedence.
Group functions operate on sets of rows to give one result per group. Some key points covered in the document include:
1. Group functions like AVG, COUNT, MAX, MIN, SUM allow aggregating data across rows grouped by columns like department.
2. The GROUP BY clause is used to divide rows into groups and column(s) in the SELECT that are not aggregate functions must be in the GROUP BY.
3. The HAVING clause is used to filter groups based on conditions with aggregate functions and comes after GROUP BY.
Subqueries allow queries to be nested within other queries. They can return either single rows or multiple rows. Single-row subqueries use comparison operators like = or >, while multiple-row subqueries use operators like IN, ANY, or ALL. Subqueries execute first before the outer or main query uses the results. This allows the main query to filter or compare based on unknown values from the subquery.
This document discusses how to limit and sort data retrieved from a database table using SQL queries. It covers using the WHERE clause to restrict rows by conditions, comparison operators like = and BETWEEN, logical operators like AND and OR, and the ORDER BY clause to sort rows in ascending or descending order based on one or more columns. Examples are provided for each technique.
This document discusses views in Oracle databases. It defines a view as a virtual table derived from one or more underlying base tables or other views. The document covers how to create simple and complex views, modify view definitions, perform DML operations on views, and remove views. Key points include that views allow restricting access, simplifying queries, and presenting different perspectives of the same data without affecting the base tables.
This document discusses techniques for joining data from multiple database tables. It covers equijoins to retrieve matching records between tables, non-equijoins to retrieve records with non-equal conditions, outer joins to include non-matching records, and self joins to join a table to itself. Examples are provided to demonstrate how to write SQL statements to perform each type of join and include additional conditions.
This document discusses how to limit and sort data retrieved by SQL queries. It covers using the WHERE clause to restrict rows selected based on conditions, comparison operators like = and BETWEEN, logical operators like AND and OR, and the ORDER BY clause to sort rows in ascending or descending order. Examples are provided for each concept to demonstrate proper SQL syntax. The overall goal is to teach how to selectively retrieve only the relevant data needed from a database table.
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 provides an overview of basic SQL statements and capabilities. It discusses using SELECT statements to project columns, select rows, and join tables. It also covers arithmetic expressions, column aliases, concatenation, and eliminating duplicate rows. SQL statements are executed through the SQL*Plus environment, which allows editing, saving, and running SQL code and commands.
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.
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.
This document discusses data manipulation in Oracle databases. It describes how to insert, update, and delete rows from tables using DML statements like INSERT, UPDATE, and DELETE. It also covers transaction management using COMMIT, ROLLBACK, and SAVEPOINT statements to control when changes are committed to the database or rolled back. Key aspects covered include inserting new rows, updating and deleting specific rows or all rows, and handling integrity constraints and transactions.
This document discusses relational databases and the Oracle implementation. It introduces relational database concepts like tables, relations, keys and SQL. It describes how Oracle uses SQL and the PL/SQL programming language to interact with and manage data in a relational database management system. PL/SQL allows embedding SQL statements in procedural code blocks for data manipulation and queries.
This document describes views in an Oracle database. It defines what a view is, explains why they are used to restrict access, simplify queries, and provide different perspectives on the same data. It covers how to create simple and complex views, retrieve data from views, modify data through views depending on their definition, and remove views. The key points are that views allow logical abstraction of data without changing the physical storage and have benefits for access control, query optimization, and data independence.
حل اسئلة الكتاب السعودى فى شرح قواعد البيانات اوراكلMohamed Moustafa
The document contains examples of SQL queries on Oracle database tables. It shows how to retrieve data from the DEPT and EMP tables, including selecting columns, filtering rows, sorting results, and performing calculations. Various SQL functions are demonstrated like INITCAP, LENGTH, SUBSTR, and date formatting. The last section aggregates data from the EMP table using MAX, MIN, SUM, and AVG.
A view allows users to access data from one or more tables in a database. Views can simplify queries, restrict access to data, and present alternative perspectives of the underlying data. The document describes how to create simple and complex views, add constraints to views, modify data through views, and remove views from the database. Views provide a way to access data without allowing direct modification of the base tables.
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.
The document describes various data manipulation language (DML) commands in Oracle such as INSERT, SELECT, UPDATE, DELETE, logical operators, pattern matching, aggregate functions, and date functions. Examples are provided to demonstrate inserting, selecting, updating, deleting records from a table and using functions to analyze and retrieve data based on conditions.
The document discusses how to create and manage database tables. Key topics covered include using CREATE TABLE to define table structure, ALTER TABLE to modify tables, DROP TABLE to remove tables, and TRUNCATE TABLE to delete all rows. Datatypes, naming conventions, adding comments, and joining tables with subqueries are also summarized.
The document discusses data manipulation language (DML) statements in SQL. It describes how to insert rows into a table using INSERT, update rows using UPDATE, and delete rows from a table using DELETE. It also covers transaction control using COMMIT to save changes permanently and ROLLBACK to undo pending changes back to a savepoint.
Constraints enforce rules at the table level to maintain data integrity. The main types of constraints are NOT NULL, UNIQUE, PRIMARY KEY, FOREIGN KEY, and CHECK. Constraints can be created at table creation or added later using ALTER TABLE. Constraint information is stored in data dictionary views like USER_CONSTRAINTS and USER_CONS_COLUMNS which can be queried.
The document discusses different ways to avoid mutating table errors when using triggers in Oracle:
1. Use a compound trigger instead of a row-level trigger to avoid the error. A compound trigger allows initializing variables before and after statements to prevent mutating errors.
2. An example is given of a compound trigger that enforces a business rule limiting salary increases to 10% of the department average without causing a mutating error.
3. The mutating error occurs when a trigger references the table that owns the trigger, preventing the trigger from seeing changes made by its own statement.
1. The document discusses various SQL commands for creating, manipulating, and querying database tables. It covers commands like CREATE TABLE, INSERT, SELECT, UPDATE, DELETE, ALTER TABLE, COMMENT, and more.
2. Mathematical functions like COUNT, MAX, MIN, ROUND, TRUNC are described along with logical and comparison operators.
3. The document provides examples of using operators, functions, joins and grouping with detailed explanations.
The document contains information about SQL functions organized into multiple chapters. Chapter 1 discusses basic SQL queries using SELECT statements and operators like arithmetic operators, concatenation, aliases and DISTINCT. Chapter 2 covers the WHERE clause and comparison operators as well as NULL values, BETWEEN, IN, LIKE and logical operators. Chapter 3 describes different categories of single row functions including character functions like UPPER, LOWER, INITCAP as well as number functions like ROUND and TRUNC, and date functions for performing calculations on dates.
This document discusses various ways to customize SQL*Plus and produce more readable output, including:
1) Using substitution variables to prompt for input and dynamically alter queries, reports, and file names.
2) Defining variables with DEFINE and ACCEPT and passing values between SQL statements.
3) Customizing the SQL*Plus environment with SET commands and verifying settings with SHOW.
The document provides an overview of SQL commands divided into DDL, DML, and DCL categories. DDL includes commands like CREATE, ALTER, and DROP for defining and modifying database schema. DML includes commands like SELECT, INSERT, UPDATE, and DELETE for manipulating data. DCL includes COMMIT, ROLLBACK, and SAVEPOINT for transaction control. Examples of each command are listed along with basic usage examples for DDL, DML, and DCL commands to practice creating tables, inserting, updating, deleting data, and managing transactions.
This document discusses restricting and sorting data in Oracle. It covers limiting rows using the WHERE clause, sorting rows using the ORDER BY clause, and using ampersand substitution in iSQL*Plus to restrict and sort output at runtime. Comparison operators, logical operators, NULL conditions, character strings, dates and BETWEEN/IN/LIKE conditions for the WHERE clause are explained. Best practices for ORDER BY are also provided.
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 provides an overview of basic SQL statements and capabilities. It discusses using SELECT statements to project columns, select rows, and join tables. It also covers arithmetic expressions, column aliases, concatenation, and eliminating duplicate rows. SQL statements are executed through the SQL*Plus environment, which allows editing, saving, and running SQL code and commands.
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.
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.
This document discusses data manipulation in Oracle databases. It describes how to insert, update, and delete rows from tables using DML statements like INSERT, UPDATE, and DELETE. It also covers transaction management using COMMIT, ROLLBACK, and SAVEPOINT statements to control when changes are committed to the database or rolled back. Key aspects covered include inserting new rows, updating and deleting specific rows or all rows, and handling integrity constraints and transactions.
This document discusses relational databases and the Oracle implementation. It introduces relational database concepts like tables, relations, keys and SQL. It describes how Oracle uses SQL and the PL/SQL programming language to interact with and manage data in a relational database management system. PL/SQL allows embedding SQL statements in procedural code blocks for data manipulation and queries.
This document describes views in an Oracle database. It defines what a view is, explains why they are used to restrict access, simplify queries, and provide different perspectives on the same data. It covers how to create simple and complex views, retrieve data from views, modify data through views depending on their definition, and remove views. The key points are that views allow logical abstraction of data without changing the physical storage and have benefits for access control, query optimization, and data independence.
حل اسئلة الكتاب السعودى فى شرح قواعد البيانات اوراكلMohamed Moustafa
The document contains examples of SQL queries on Oracle database tables. It shows how to retrieve data from the DEPT and EMP tables, including selecting columns, filtering rows, sorting results, and performing calculations. Various SQL functions are demonstrated like INITCAP, LENGTH, SUBSTR, and date formatting. The last section aggregates data from the EMP table using MAX, MIN, SUM, and AVG.
A view allows users to access data from one or more tables in a database. Views can simplify queries, restrict access to data, and present alternative perspectives of the underlying data. The document describes how to create simple and complex views, add constraints to views, modify data through views, and remove views from the database. Views provide a way to access data without allowing direct modification of the base tables.
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.
The document describes various data manipulation language (DML) commands in Oracle such as INSERT, SELECT, UPDATE, DELETE, logical operators, pattern matching, aggregate functions, and date functions. Examples are provided to demonstrate inserting, selecting, updating, deleting records from a table and using functions to analyze and retrieve data based on conditions.
The document discusses how to create and manage database tables. Key topics covered include using CREATE TABLE to define table structure, ALTER TABLE to modify tables, DROP TABLE to remove tables, and TRUNCATE TABLE to delete all rows. Datatypes, naming conventions, adding comments, and joining tables with subqueries are also summarized.
The document discusses data manipulation language (DML) statements in SQL. It describes how to insert rows into a table using INSERT, update rows using UPDATE, and delete rows from a table using DELETE. It also covers transaction control using COMMIT to save changes permanently and ROLLBACK to undo pending changes back to a savepoint.
Constraints enforce rules at the table level to maintain data integrity. The main types of constraints are NOT NULL, UNIQUE, PRIMARY KEY, FOREIGN KEY, and CHECK. Constraints can be created at table creation or added later using ALTER TABLE. Constraint information is stored in data dictionary views like USER_CONSTRAINTS and USER_CONS_COLUMNS which can be queried.
The document discusses different ways to avoid mutating table errors when using triggers in Oracle:
1. Use a compound trigger instead of a row-level trigger to avoid the error. A compound trigger allows initializing variables before and after statements to prevent mutating errors.
2. An example is given of a compound trigger that enforces a business rule limiting salary increases to 10% of the department average without causing a mutating error.
3. The mutating error occurs when a trigger references the table that owns the trigger, preventing the trigger from seeing changes made by its own statement.
1. The document discusses various SQL commands for creating, manipulating, and querying database tables. It covers commands like CREATE TABLE, INSERT, SELECT, UPDATE, DELETE, ALTER TABLE, COMMENT, and more.
2. Mathematical functions like COUNT, MAX, MIN, ROUND, TRUNC are described along with logical and comparison operators.
3. The document provides examples of using operators, functions, joins and grouping with detailed explanations.
The document contains information about SQL functions organized into multiple chapters. Chapter 1 discusses basic SQL queries using SELECT statements and operators like arithmetic operators, concatenation, aliases and DISTINCT. Chapter 2 covers the WHERE clause and comparison operators as well as NULL values, BETWEEN, IN, LIKE and logical operators. Chapter 3 describes different categories of single row functions including character functions like UPPER, LOWER, INITCAP as well as number functions like ROUND and TRUNC, and date functions for performing calculations on dates.
This document discusses various ways to customize SQL*Plus and produce more readable output, including:
1) Using substitution variables to prompt for input and dynamically alter queries, reports, and file names.
2) Defining variables with DEFINE and ACCEPT and passing values between SQL statements.
3) Customizing the SQL*Plus environment with SET commands and verifying settings with SHOW.
The document provides an overview of SQL commands divided into DDL, DML, and DCL categories. DDL includes commands like CREATE, ALTER, and DROP for defining and modifying database schema. DML includes commands like SELECT, INSERT, UPDATE, and DELETE for manipulating data. DCL includes COMMIT, ROLLBACK, and SAVEPOINT for transaction control. Examples of each command are listed along with basic usage examples for DDL, DML, and DCL commands to practice creating tables, inserting, updating, deleting data, and managing transactions.
This document discusses restricting and sorting data in Oracle. It covers limiting rows using the WHERE clause, sorting rows using the ORDER BY clause, and using ampersand substitution in iSQL*Plus to restrict and sort output at runtime. Comparison operators, logical operators, NULL conditions, character strings, dates and BETWEEN/IN/LIKE conditions for the WHERE clause are explained. Best practices for ORDER BY are also provided.
This document discusses restricting and sorting data in SQL queries. It covers limiting rows using the WHERE clause with comparison, BETWEEN, IN, LIKE, and NULL conditions. Logical operators like AND, OR, and NOT are also covered. The ORDER BY clause is discussed for sorting query results in ascending or descending order by one or multiple columns. Examples are provided for each concept to illustrate their proper usage in SELECT statements.
Lightning Talk #9: How UX and Data Storytelling Can Shape Policy by Mika Aldabaux singapore
How can we take UX and Data Storytelling out of the tech context and use them to change the way government behaves?
Showcasing the truth is the highest goal of data storytelling. Because the design of a chart can affect the interpretation of data in a major way, one must wield visual tools with care and deliberation. Using quantitative facts to evoke an emotional response is best achieved with the combination of UX and data storytelling.
The document discusses how personalization and dynamic content are becoming increasingly important on websites. It notes that 52% of marketers see content personalization as critical and 75% of consumers like it when brands personalize their content. However, personalization can create issues for search engine optimization as dynamic URLs and content are more difficult for search engines to index than static pages. The document provides tips for SEOs to help address these personalization and SEO challenges, such as using static URLs when possible and submitting accurate sitemaps.
This document summarizes a study of CEO succession events among the largest 100 U.S. corporations between 2005-2015. The study analyzed executives who were passed over for the CEO role ("succession losers") and their subsequent careers. It found that 74% of passed over executives left their companies, with 30% eventually becoming CEOs elsewhere. However, companies led by succession losers saw average stock price declines of 13% over 3 years, compared to gains for companies whose CEO selections remained unchanged. The findings suggest that boards generally identify the most qualified CEO candidates, though differences between internal and external hires complicate comparisons.
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.
This document discusses how to limit and sort data retrieved by SQL queries. It describes using the WHERE clause to restrict rows selected and comparison/logical operators like =, BETWEEN, IN, AND and OR in the WHERE clause. It also covers sorting result sets using the ORDER BY clause and specifying ascending or descending order.
This document discusses how to limit and sort data retrieved by SQL queries. It describes using the WHERE clause to restrict rows selected and comparison operators like =, <, and BETWEEN to define conditions. The ORDER BY clause allows sorting retrieved rows in ascending or descending order based on column values. Logical operators like AND, OR, and NOT can combine conditions.
This document discusses how to limit and sort data retrieved by SQL queries. It describes using the WHERE clause to restrict rows selected and comparison operators like =, <, and BETWEEN to define conditions. The ORDER BY clause allows sorting retrieved rows in ascending or descending order based on column values. Logical operators like AND, OR, and NOT can combine conditions.
This document provides an overview of basic SQL statements and SQL*Plus commands. It covers SELECT statements to retrieve data from one or more tables, including selecting specific columns, adding column aliases, and performing arithmetic calculations. It also discusses eliminating duplicate rows, concatenating columns, using literal strings, and describing table structures. The key aspects covered are the basic SELECT statement syntax, capabilities of SQL SELECT statements, and using SQL*Plus as an environment to execute and edit SQL statements.
These slides are from OpenWorld 2018. We covered
- conventional CONNECT BY syntax in Oracle
- extensions that were introduced in more recent versions
- the recursive WITH clause
Slides from OpenWorld 2013 presentation.
Analytics have been there since 8.1.6, but they are still dramatically underused by application developers. This session looks at the syntax and usage of analytic functions, and how they can supercharge your SQL skillset.
This document contains the SQL queries and results from 16 different assignments on an EMPLOYEES table. The queries retrieve employee details like names, salaries, departments and more. Some key results are: 8 employees joined before September 30, 1981; there are 5 different designations in the company; the total salaries paid is 29,025; and the maximum, minimum and average salaries are 5000, 800 and 2073.21 respectively.
This document contains examples of SQL queries being run on database tables to retrieve various data. The queries demonstrate selecting data from tables, filtering on conditions, using aggregation functions like COUNT and AVG, joining tables, and more. The tables being queried include EMP, DEPT, and other tables containing employee and department data.
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
Analytic SQL functions, or "window functions have been there since 8.1.6, but they are still dramatically underused by application developers. This session looks at the syntax and usage of analytic functions, and how they can supercharge your SQL skillset.
Covers analytics from their inception in 8.1.6 all the through to enhancements in 18 and 19
This document provides an overview of Oracle SQL functions. It discusses single-row functions that operate on each row returned, including conversion, character, number, and date functions. Character functions covered include LOWER, UPPER, INITCAP, CONCAT, SUBSTR, LENGTH, and INSTR, which can be used for case conversion and character manipulation.
The document appears to be a presentation on window functions in SQL. It provides examples of different types of window functions including ranking functions like RANK, DENSE_RANK, and ROW_NUMBER. It also shows aggregation functions used in window functions like SUM, COUNT, and AVG. Examples calculate ranking of employee hires and running totals of salaries by department. The presentation emphasizes the simple syntax of window functions and their use in analytic queries.
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.
Get your moneys worth out of your databasePatrick Barel
This document contains information about Patrick Barel including his contact details, work experience, blog and website links. It discusses database topics like data integrity, flashback queries, and temporal validity. Examples are provided to demonstrate how to ensure data integrity through constraints, use flashback queries to view past data states, and implement temporal tables to track valid time periods for rows.
The document discusses using cursors and triggers in SQL procedures. It describes how cursors allow defining and iterating through a result set row by row. Triggers allow running code automatically when data changes, such as on insert, update or delete operations. An example cursor program selects the top 5 paid employees from a table and inserts their data into another table. An example trigger inserts a record into a log table each time a row is updated in another table.
1. Oracle Database 11g Release 2 introduced deferred segment creation, which allows segments like tables and indexes to delay allocating their initial extent until the first row is inserted. This avoids unnecessary upfront space usage for segments that may see little actual data.
2. Traditionally, segments would allocate space for the initial extent immediately upon creation. But many applications create thousands of tables where only a small subset see real use.
3. With deferred segment creation, space is only used when needed, improving space efficiency for applications that create many rarely used segments.
The document provides an overview of basic SQL statements and SELECT capabilities. It discusses selecting columns, arithmetic expressions, null values, column aliases, concatenation, literals, and duplicate rows. Examples are given to demonstrate SELECT statements, column selection, calculations, aliases, concatenation, literals, and DISTINCT. The document also describes displaying table structure using the DESCRIBE command in SQL*Plus.
Do you want to get up to speed with the most current release of Oracle Database? If so, this session is for you. You will learn about the most exciting and useful new features of Oracle Database 12c that can make your work as a database developer a lot easier. There is more to Oracle Database 12c than just pluggable databases.
Webinar: Designing a schema for a Data WarehouseFederico Razzoli
Are you new to data warehouses (DWH)? Do you need to check whether your data warehouse follows the best practices for a good design? In both cases, this webinar is for you.
A data warehouse is a central relational database that contains all measurements about a business or an organisation. This data comes from a variety of heterogeneous data sources, which includes databases of any type that back the applications used by the company, data files exported by some applications, or APIs provided by internal or external services.
But designing a data warehouse correctly is a hard task, which requires gathering information about the business processes that need to be analysed in the first place. These processes must be translated into so-called star schemas, which means, denormalised databases where each table represents a dimension or facts.
We will discuss these topics:
- How to gather information about a business;
- Understanding dictionaries and how to identify business entities;
- Dimensions and facts;
- Setting a table granularity;
- Types of facts;
- Types of dimensions;
- Snowflakes and how to avoid them;
- Expanding existing dimensions and facts.
Ocean lotus Threat actors project by John Sitima 2024 (1).pptxSitimaJohn
Ocean Lotus cyber threat actors represent a sophisticated, persistent, and politically motivated group that poses a significant risk to organizations and individuals in the Southeast Asian region. Their continuous evolution and adaptability underscore the need for robust cybersecurity measures and international cooperation to identify and mitigate the threats posed by such advanced persistent threat groups.
Main news related to the CCS TSI 2023 (2023/1695)Jakub Marek
An English 🇬🇧 translation of a presentation to the speech I gave about the main changes brought by CCS TSI 2023 at the biggest Czech conference on Communications and signalling systems on Railways, which was held in Clarion Hotel Olomouc from 7th to 9th November 2023 (konferenceszt.cz). Attended by around 500 participants and 200 on-line followers.
The original Czech 🇨🇿 version of the presentation can be found here: https://www.slideshare.net/slideshow/hlavni-novinky-souvisejici-s-ccs-tsi-2023-2023-1695/269688092 .
The videorecording (in Czech) from the presentation is available here: https://youtu.be/WzjJWm4IyPk?si=SImb06tuXGb30BEH .
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAUpanagenda
Webinar Recording: https://www.panagenda.com/webinars/hcl-notes-und-domino-lizenzkostenreduzierung-in-der-welt-von-dlau/
DLAU und die Lizenzen nach dem CCB- und CCX-Modell sind für viele in der HCL-Community seit letztem Jahr ein heißes Thema. Als Notes- oder Domino-Kunde haben Sie vielleicht mit unerwartet hohen Benutzerzahlen und Lizenzgebühren zu kämpfen. Sie fragen sich vielleicht, wie diese neue Art der Lizenzierung funktioniert und welchen Nutzen sie Ihnen bringt. Vor allem wollen Sie sicherlich Ihr Budget einhalten und Kosten sparen, wo immer möglich. Das verstehen wir und wir möchten Ihnen dabei helfen!
Wir erklären Ihnen, wie Sie häufige Konfigurationsprobleme lösen können, die dazu führen können, dass mehr Benutzer gezählt werden als nötig, und wie Sie überflüssige oder ungenutzte Konten identifizieren und entfernen können, um Geld zu sparen. Es gibt auch einige Ansätze, die zu unnötigen Ausgaben führen können, z. B. wenn ein Personendokument anstelle eines Mail-Ins für geteilte Mailboxen verwendet wird. Wir zeigen Ihnen solche Fälle und deren Lösungen. Und natürlich erklären wir Ihnen das neue Lizenzmodell.
Nehmen Sie an diesem Webinar teil, bei dem HCL-Ambassador Marc Thomas und Gastredner Franz Walder Ihnen diese neue Welt näherbringen. Es vermittelt Ihnen die Tools und das Know-how, um den Überblick zu bewahren. Sie werden in der Lage sein, Ihre Kosten durch eine optimierte Domino-Konfiguration zu reduzieren und auch in Zukunft gering zu halten.
Diese Themen werden behandelt
- Reduzierung der Lizenzkosten durch Auffinden und Beheben von Fehlkonfigurationen und überflüssigen Konten
- Wie funktionieren CCB- und CCX-Lizenzen wirklich?
- Verstehen des DLAU-Tools und wie man es am besten nutzt
- Tipps für häufige Problembereiche, wie z. B. Team-Postfächer, Funktions-/Testbenutzer usw.
- Praxisbeispiele und Best Practices zum sofortigen Umsetzen
Threats to mobile devices are more prevalent and increasing in scope and complexity. Users of mobile devices desire to take full advantage of the features
available on those devices, but many of the features provide convenience and capability but sacrifice security. This best practices guide outlines steps the users can take to better protect personal devices and information.
GraphRAG for Life Science to increase LLM accuracyTomaz Bratanic
GraphRAG for life science domain, where you retriever information from biomedical knowledge graphs using LLMs to increase the accuracy and performance of generated answers
UiPath Test Automation using UiPath Test Suite series, part 6DianaGray10
Welcome to UiPath Test Automation using UiPath Test Suite series part 6. In this session, we will cover Test Automation with generative AI and Open AI.
UiPath Test Automation with generative AI and Open AI webinar offers an in-depth exploration of leveraging cutting-edge technologies for test automation within the UiPath platform. Attendees will delve into the integration of generative AI, a test automation solution, with Open AI advanced natural language processing capabilities.
Throughout the session, participants will discover how this synergy empowers testers to automate repetitive tasks, enhance testing accuracy, and expedite the software testing life cycle. Topics covered include the seamless integration process, practical use cases, and the benefits of harnessing AI-driven automation for UiPath testing initiatives. By attending this webinar, testers, and automation professionals can gain valuable insights into harnessing the power of AI to optimize their test automation workflows within the UiPath ecosystem, ultimately driving efficiency and quality in software development processes.
What will you get from this session?
1. Insights into integrating generative AI.
2. Understanding how this integration enhances test automation within the UiPath platform
3. Practical demonstrations
4. Exploration of real-world use cases illustrating the benefits of AI-driven test automation for UiPath
Topics covered:
What is generative AI
Test Automation with generative AI and Open AI.
UiPath integration with generative AI
Speaker:
Deepak Rai, Automation Practice Lead, Boundaryless Group and UiPath MVP
Building Production Ready Search Pipelines with Spark and MilvusZilliz
Spark is the widely used ETL tool for processing, indexing and ingesting data to serving stack for search. Milvus is the production-ready open-source vector database. In this talk we will show how to use Spark to process unstructured data to extract vector representations, and push the vectors to Milvus vector database for search serving.
Skybuffer SAM4U tool for SAP license adoptionTatiana Kojar
Manage and optimize your license adoption and consumption with SAM4U, an SAP free customer software asset management tool.
SAM4U, an SAP complimentary software asset management tool for customers, delivers a detailed and well-structured overview of license inventory and usage with a user-friendly interface. We offer a hosted, cost-effective, and performance-optimized SAM4U setup in the Skybuffer Cloud environment. You retain ownership of the system and data, while we manage the ABAP 7.58 infrastructure, ensuring fixed Total Cost of Ownership (TCO) and exceptional services through the SAP Fiori interface.
Ivanti’s Patch Tuesday breakdown goes beyond patching your applications and brings you the intelligence and guidance needed to prioritize where to focus your attention first. Catch early analysis on our Ivanti blog, then join industry expert Chris Goettl for the Patch Tuesday Webinar Event. There we’ll do a deep dive into each of the bulletins and give guidance on the risks associated with the newly-identified vulnerabilities.
OpenID AuthZEN Interop Read Out - AuthorizationDavid Brossard
During Identiverse 2024 and EIC 2024, members of the OpenID AuthZEN WG got together and demoed their authorization endpoints conforming to the AuthZEN API
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
Salesforce Integration for Bonterra Impact Management (fka Social Solutions A...Jeffrey Haguewood
Sidekick Solutions uses Bonterra Impact Management (fka Social Solutions Apricot) and automation solutions to integrate data for business workflows.
We believe integration and automation are essential to user experience and the promise of efficient work through technology. Automation is the critical ingredient to realizing that full vision. We develop integration products and services for Bonterra Case Management software to support the deployment of automations for a variety of use cases.
This video focuses on integration of Salesforce with Bonterra Impact Management.
Interested in deploying an integration with Salesforce for Bonterra Impact Management? Contact us at sales@sidekicksolutionsllc.com to discuss next steps.
Digital Marketing Trends in 2024 | Guide for Staying AheadWask
https://www.wask.co/ebooks/digital-marketing-trends-in-2024
Feeling lost in the digital marketing whirlwind of 2024? Technology is changing, consumer habits are evolving, and staying ahead of the curve feels like a never-ending pursuit. This e-book is your compass. Dive into actionable insights to handle the complexities of modern marketing. From hyper-personalization to the power of user-generated content, learn how to build long-term relationships with your audience and unlock the secrets to success in the ever-shifting digital landscape.
3. Using the WHERE Clause SQL> SELECT ename, job, deptno 2 FROM emp 3 WHERE job='CLERK'; ENAME JOB DEPTNO ---------- --------- --------- JAMES CLERK 30 SMITH CLERK 20 ADAMS CLERK 20 MILLER CLERK 10
4.
5. Comparison Operators Operator = > >= < <= <> Meaning Equal to Greater than Greater than or equal to Less than Less than or equal to Not equal to
6. Using the Comparison Operators SQL> SELECT ename, sal, comm 2 FROM emp 3 WHERE sal<=comm; ENAME SAL COMM ---------- --------- --------- MARTIN 1250 1400
7. Other Comparison Operators Operator BETWEEN ...AND... IN(list) LIKE IS NULL Meaning Between two values (inclusive) Match any of a list of values Match a character pattern Is a null value
8.
9. Using the IN Operator SQL> SELECT empno, ename, sal, mgr 2 FROM emp 3 WHERE mgr IN (7902, 7566, 7788); EMPNO ENAME SAL MGR --------- ---------- --------- --------- 7902 FORD 3000 7566 7369 SMITH 800 7902 7788 SCOTT 3000 7566 7876 ADAMS 1100 7788
10.
11.
12.
13. Logical Operators Operator AND OR NOT Meaning Returns TRUE if both component conditions are TRUE Returns TRUE if either component condition is TRUE Returns TRUE if the following condition is FALSE
14. Using the AND Operator AND requires both conditions to be TRUE. SQL> SELECT empno, ename, job, sal 2 FROM emp 3 WHERE sal>=1100 4 AND job='CLERK'; EMPNO ENAME JOB SAL --------- ---------- --------- --------- 7876 ADAMS CLERK 1100 7934 MILLER CLERK 1300
15.
16. Using the NOT Operator SQL> SELECT ename, job 2 FROM emp 3 WHERE job NOT IN ('CLERK','MANAGER','ANALYST'); ENAME JOB ---------- --------- KING PRESIDENT MARTIN SALESMAN ALLEN SALESMAN TURNER SALESMAN WARD SALESMAN
17.
18. Rules of Precedence ENAME JOB SAL ---------- --------- --------- KING PRESIDENT 5000 MARTIN SALESMAN 1250 ALLEN SALESMAN 1600 TURNER SALESMAN 1500 WARD SALESMAN 1250 SQL> SELECT ename, job, sal 2 FROM emp 3 WHERE job='SALESMAN' 4 OR job='PRESIDENT' 5 AND sal>1500;
19. Rules of Precedence ENAME JOB SAL ---------- --------- --------- KING PRESIDENT 5000 ALLEN SALESMAN 1600 Use parentheses to force priority. SQL> SELECT ename, job, sal 2 FROM emp 3 WHERE (job='SALESMAN' 4 OR job='PRESIDENT') 5 AND sal>1500;
20.
21. Sorting in Descending Order SQL> SELECT ename, job, deptno, hiredate 2 FROM emp 3 ORDER BY hiredate DESC; ENAME JOB DEPTNO HIREDATE ---------- --------- --------- --------- ADAMS CLERK 20 12-JAN-83 SCOTT ANALYST 20 09-DEC-82 MILLER CLERK 10 23-JAN-82 JAMES CLERK 30 03-DEC-81 FORD ANALYST 20 03-DEC-81 KING PRESIDENT 10 17-NOV-81 MARTIN SALESMAN 30 28-SEP-81 ... 14 rows selected.
22. Sorting by Column Alias SQL> SELECT empno, ename, sal*12 annsal 2 FROM emp 3 ORDER BY annsal; EMPNO ENAME ANNSAL --------- ---------- --------- 7369 SMITH 9600 7900 JAMES 11400 7876 ADAMS 13200 7654 MARTIN 15000 7521 WARD 15000 7934 MILLER 15600 7844 TURNER 18000 ... 14 rows selected.
23.
24. Summary SELECT [DISTINCT] {*| column [ alias ], ...} FROM table [WHERE condition(s) ] [ORDER BY { column, expr, alias } [ASC|DESC]];
25.
Editor's Notes
Schedule: Timing Topic 45 minutes Lecture 30 minutes Practice 75 minutes Total
Limiting Rows Selected You can restrict the rows returned from the query by using the WHERE clause. A WHERE clause contains a condition that must be met, and it directly follows the FROM clause. In the syntax: WHERE restricts the query to rows that meet a condition condition is composed of column names, expressions, constants, and a comparison operator The WHERE clause can compare values in columns, literal values, arithmetic expressions, or functions. The WHERE clause consists of three elements: Column name Comparison operator Column name, constant, or list of values
Using the WHERE Clause In the example, the SELECT statement retrieves the name, job title, and department number of all employees whose job title is CLERK. Note that the job title CLERK has been specified in uppercase to ensure that the match is made with the job column in the EMP table. Character strings are case sensitive. Instructor Note Snippet: “Processing a Query”
Character Strings and Dates Character strings and dates in the WHERE clause must be enclosed in single quotation marks ( '' ). Number constants, however, should not. All character searches are case sensitive. In the following example, no rows are returned because the EMP table stores all the data in uppercase: SQL> SELECT ename, empno, job, deptno 2 FROM emp 3 WHERE job='clerk'; Oracle stores dates in an internal numeric format, representing the century, year, month, day, hours, minutes, and seconds. The default date display is DD-MON-YY. Note: Changing default date format will be covered in a subsequent lesson. Number values are not enclosed within quotation marks. Instructor Note Some students may ask how to override the case sensitivity. Later in the course, we will cover the use of single-row functions such as UPPER and LOWER to override the case sensitivity.
Comparison Operators Comparison operators are used in conditions that compare one expression to another. They are used in the WHERE clause in the following format: Syntax … WHERE expr operator value Examples … WHERE hiredate='01-JAN-95' … WHERE sal>=1500 … WHERE ename='SMITH' Instructor Note Remind students that the expr cannot be an alias. Mention in brief about the date TO_DATE function, when the date is to be entered in a format other than the default format. This is required for practice 4.
Using the Comparison Operators In the example, the SELECT statement retrieves name, salary, and commission from the EMP table, where the employee salary is less than or equal to the commission amount. Note that there is no explicit value supplied to the WHERE clause. The two values being compared are taken from the SAL and COMM columns in the EMP table. Instructor Note Rows that have a null value in the COMM column result in a null value for the comparison expression and are effectively not part of the result.
The BETWEEN Operator You can display rows based on a range of values using the BETWEEN operator. The range that you specify contains a lower range and an upper range. The SELECT statement on the slide returns rows from the EMP table for any employee whose salary is between $1000 and $1500. Values specified with the BETWEEN operator are inclusive. You must specify the lower limit first. Instructor Note Emphasize that the values specified with the BETWEEN operator in the example are inclusive. Point out that Turner, who earns $1500 (higher limit), is included in the output. Explain that BETWEEN … AND … are actually translated by Oracle server to a pair of AND conditions, (a >= lower limit) and (a <= higher limit). So using BETWEEN … AND … has no performance benefits and can be used for logical simplicity. Demo: l2betw.sql Purpose: To illustrate using the BETWEEN operator.
The IN Operator To test for values in a specified list, use the IN operator. The slide example displays employee number, name, salary, and manager’s employee number of all the employees whose manager’s employee number is 7902, 7566, or 7788. The IN operator can be used with any datatype. The following example returns a row from the EMP table for any employee whose name is included in the list of names in the WHERE clause: SQL> SELECT empno, ename, mgr, deptno 2 FROM emp 3 WHERE ename IN ('FORD' , 'ALLEN'); If characters or dates are used in the list, they must be enclosed in single quotation marks ( '' ). Instructor Note Explain that the IN ( … ) is actually translated by Oracle server to a set of OR conditions (a = value1 OR a = value2 OR a = value3 ). So using IN ( … ) has no performance benefits and can be used for logical simplicity. Demo: l2in.sql Purpose: To illustrate using the IN operator.
The LIKE Operator You may not always know the exact value to search for. You can select rows that match a character pattern by using the LIKE operator. The character pattern-matching operation is referred to as a wildcard search. Two symbols can be used to construct the search string. The SELECT statement above returns the employee name from the EMP table for any employee whose name begins with an “S.” Note the uppercase “S.” Names beginning with an “s” will not be returned. The LIKE operator can be used as a shortcut for some BETWEEN comparisons. The following example displays names and hire dates of all employees who joined between January 1981 and December 1981: SQL> SELECT ename, hiredate 2 FROM emp 3 WHERE hiredate LIKE '%1981';
Combining Wildcard Characters The % and _ symbols can be used in any combination with literal characters. The example on the slide displays the names of all employees whose name has an “A” as the second character. The ESCAPE Option When you need to have an exact match for the actual ‘%’ and ‘_’ characters, use the ESCAPE option. This option specifies what the ESCAPE character is. If you have HEAD_QUARTERS as a department name, you would search for it using the following SQL statement: The ESCAPE option identifies the backslash (\\) as the escape character. In the pattern, the escape character precedes the underscore (_). This causes the Oracle Server to interpret the underscore literally. SQL> SELECT * FROM dept 2 WHERE dname LIKE ' %\\_% ' ESCAPE '\\'; DEPTNO DNAME LOC --------- -------------- ------------- 50 HEAD_QUARTERS ATLANTA
The IS NULL Operator The IS NULL operator tests for values that are null. A null value means the value is unavailable, unassigned, unknown, or inapplicable. Therefore, you cannot test with (=) because a null value cannot be equal or unequal to any value. The slide example retrieves the name and manager of all employees who do not have a manager. For example, to display name, job title, and commission for all employees who are not entitled to get a commission, use the following SQL statement: SQL> SELECT ename, job, comm 2 FROM emp 3 WHERE comm IS NULL; ENAME JOB COMM -------- ----------- ------ KING PRESIDENT BLAKE MANAGER CLARK MANAGER ...
Logical Operators A logical operator combines the result of two component conditions to produce a single result based on them or to invert the result of a single condition. Three logical operators are available in SQL: AND OR NOT All the examples so far have specified only one condition in the WHERE clause. You can use several conditions in one WHERE clause using the AND and OR operators.
The AND Operator In the example, both conditions must be true for any record to be selected. Therefore, an employee who has a job title of CLERK and earns more than $1100 will be selected. All character searches are case sensitive. No rows are returned if CLERK is not in uppercase. Character strings must be enclosed in quotation marks. AND Truth Table The following table shows the results of combining two expressions with AND: Instructor Note Demo: l2and.sql Purpose: To illustrate using the AND operator.
The OR Operator In the example, either condition can be true for any record to be selected. Therefore, an employee who has a job title of CLERK or earns more than $1100 will be selected. The OR Truth Table The following table shows the results of combining two expressions with OR: Instructor Note Demo: l2or.sql Purpose: To illustrate using the OR operator.
The NOT Operator The slide example displays name and job title of all the employees whose job title is not CLERK, MANAGER, or ANALYST. The NOT Truth Table The following table shows the result of applying the NOT operator to a condition: Note: The NOT operator can also be used with other SQL operators, such as BETWEEN, LIKE, and NULL. ... WHERE job NOT IN ('CLERK', 'ANALYST') ... WHERE sal NOT BETWEEN 1000 AND 1500 ... WHERE ename NOT LIKE '%A%' ... WHERE comm IS NOT NULL
Example of Precedence of AND Operator In the slide example, there are two conditions: The first condition is that job is PRESIDENT and salary is greater than 1500. The second condition is that job is SALESMAN. Therefore, the SELECT statement reads as follows: “ Select the row if an employee is a PRESIDENT and earns more than $1500 or if the employee is a SALESMAN.” Instructor Note Demo: l2sal1.sql Purpose: To illustrate the rules of precedence.
Using Parentheses In the example, there are two conditions: The first condition is that job is PRESIDENT or SALESMAN. The second condition is that salary is greater than 1500. Therefore, the SELECT statement reads as follows: “ Select the row if an employee is a PRESIDENT or a SALESMAN and if the employee earns more than $1500.” Instructor Note Demo: l2sal2.sql Purpose: To illustrate the rules of precedence.
The ORDER BY Clause The order of rows returned in a query result is undefined. The ORDER BY clause can be used to sort the rows. If you use the ORDER BY clause, you must place last. You can specify an expression or an alias to sort. Syntax SELECT expr FROM table [WHERE condition(s) ] [ORDER BY { column , expr } [ASC|DESC]]; where: ORDER BY specifies the order in which the retrieved rows are displayed ASC orders the rows in ascending order (this is the default order) DESC orders the rows in descending order If the ORDER BY clause is not used, the sort order is undefined, and the Oracle Server may not fetch rows in the same order for the same query twice. Use the ORDER BY clause to display the rows in a specific order. Instructor Note Let the students know that the ORDER BY clause is executed last in query execution.
Default Ordering of Data The default sort order is ascending: Numeric values are displayed with the lowest values first—for example, 1 – 999. Date values are displayed with the earliest value first—for example, 01-JAN-92 before 01-JAN-95. Character values are displayed in alphabetical order—for example, A first and Z last. Null values are displayed last for ascending sequences and first for descending sequences. Reversing the Default Order To reverse the order in which rows are displayed, specify the keyword DESC after the column name in the ORDER BY clause. The slide example sorts the result by the most recently hired employee. Instructor Note Let the students know that you can also sort by a column number in the SELECT list. The example below will sort the output in the descending order by salary. SQL> SELECT ename, sal 2 FROM emp 3 ORDER BY 2 DESC;
Sorting by Column Aliases You can use a column alias in the ORDER BY clause. The slide example sorts the data by annual salary.
Sorting by Multiple Columns You can sort query results by more than one column. The sort limit is the number of columns in the given table. In the ORDER BY clause, specify the columns, and separate the column names using commas. If you want to reverse the order of a column, specify DESC after its name. You can order by columns that are not included in the SELECT clause. Example Display name and salary of all employees. Order the result by department number and then descending order by salary. Instructor Note Show that the DEPTNO column is sorted in ascending order and the SAL column in descending order. SQL> SELECT ename, sal 2 FROM emp 3 ORDER BY deptno, sal DESC;
Summary In this lesson, you have learned about restricting and sorting rows returned by the SELECT statement. You have also learned how to implement various operators.
Practice Overview This practice gives you a variety of exercises using the WHERE clause and the ORDER BY clause.