This presentation deals with the advanced features of SQL comprising of Arithmetic Calculations, Analytical Function, PIVOT etc. Presented by Alphalogic Inc: https://www.alphalogicinc.com/
Using and Creating SQL Functions with Ammar Hassan Brohi.
String Functions
Numeric Functions
String / Number Conversion Functions
Group Functions
Date and Time Functions
Date Conversion Functions
This presentation deals with the fundamentals of SQL, Installation and Database concepts. Presented by our team in Alphalogic Inc: https://www.alphalogicinc.com/
Using and Creating SQL Functions with Ammar Hassan Brohi.
String Functions
Numeric Functions
String / Number Conversion Functions
Group Functions
Date and Time Functions
Date Conversion Functions
This presentation deals with the fundamentals of SQL, Installation and Database concepts. Presented by our team in Alphalogic Inc: https://www.alphalogicinc.com/
Super keyword is a reference variable that is used for refer parent class object. Super keyword is used in java at three level, at variable level, at method level and at constructor level.
This keyword is a reference variable that refer the current object in java.
This keyword can be used for call current class constructor.
http://www.tutorial4us.com/java/java-this-keyword
YouTube Link: https://youtu.be/f6VWSlnHGCE
** MySQL DBA Certification Training: https://www.edureka.co/mysql-dba **
This Edureka PPT on 'SQL Triggers' will help you understand the concept of triggers in SQL. Below are the topics covered in this SQL Triggers For Beginners.
Follow us to never miss an update in the future.
YouTube: https://www.youtube.com/user/edurekaIN
Instagram: https://www.instagram.com/edureka_learning/
Facebook: https://www.facebook.com/edurekaIN/
Twitter: https://twitter.com/edurekain
LinkedIn: https://www.linkedin.com/company/edureka
Castbox: https://castbox.fm/networks/505?country=in
Collections Framework is a unified architecture for managing collections, Main Parts of Collections Framework
1. Interfaces :- Core interfaces defining common functionality exhibited by collections
2. Implementations :- Concrete classes of the core interfaces providing data structures
3. Operations :- Methods that perform various operations on collections
Loops in Java. Looping in programming languages is a feature which facilitates the execution of a set of instructions/functions repeatedly while some condition evaluates to true.
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.
Oracle Analytical Function Include First Value, Last Value, Lead, Lag, Nth Value with Unbounded and Difference between Rank and Dense Rank . Contain Rollup, Cube and Grouping and Different type of Window Function and Analytical Window frame
Are you an Oracle developer or a DBA?
Do you know the difference between aggregate and analytic functions?
Without complex sub-queries or self-joins, do you know how to:
Calculate running/cumulative totals and moving/centered averages?
List products with revenues above or below their peers or product groups?
Compute the ratio of one category’s sales to the total sales?
Select the Top-N or Top N % of the customers/products?
Classify advertisers into quartiles/n-tiles based on the revenue potential?
Compare period-over-period (year-over-year, month-over-month) growth and rank advancement?
Convert rows into columns (pivot), columns into rows (unpivot) or aggregate strings?
Perform what-if analysis and hypothetical ranking?
Analytic functions are more performant because tables need to be scanned only once. They make you more productive because there is no need to write procedural code. No wonder Tom Kyte, a well-respected Oracle guru, says analytic functions are the best thing to happen after the sliced bread.
In the first half, I will cover the basics of the various analytic functions:
Ranking: RANK, DENSE_RANK, ROW_NUMBER, NTILE, CUME_DIST, PERCENTILE_RANK
Windowing: SUM, AVG, MAX, MIN, FIRST_VALUE, LAST_VALUE
Reporting: RATIO_TO_REPORT
Others: FIRST/LAST, LEAD/LAG, hypothetical ranking,
In the second half, I will show how powerful these functions are with a few examples.
If there is time, I will cover enhanced aggregation (ROLLUP, CUBE, GROUPING SET extensions to GROUP BY clause)
This class would be useful for both developers and DBAs alike, especially for those working in Analytic, Business Intelligence, and Datawarehouse environments.
Are you already an expert in analytic functions? Then come and help me refine the content.
For more info, read
http://download.oracle.com/docs/cd/E11882_01/server.112/e16579/analysis.htm
http://download.oracle.com/docs/cd/E11882_01/server.112/e16579/aggreg.htm
rollup, cross-tabulation across different dimensions using ROLLUP, CUBE and GROUPING SETS extension to GROUP BY clause
, most active time-periods (i.e. days when the most number of tickets are open in BZ, hours with the most take-off and landings, months with the highest sales, 5-minute periods with the maximum number of calls made, etc)
data densification?
their rank last year, this year, rank growth, running/cumulative total (Year-To-Date/Month-To-Date summation), moving averages, Year-Over-Year comparison, sales projection, average/min/max time between one sale and the next sale, products with above and below average sales.
overall average, sum, departmental average, sum, ranking, job wise ranking in one SQL.
Super keyword is a reference variable that is used for refer parent class object. Super keyword is used in java at three level, at variable level, at method level and at constructor level.
This keyword is a reference variable that refer the current object in java.
This keyword can be used for call current class constructor.
http://www.tutorial4us.com/java/java-this-keyword
YouTube Link: https://youtu.be/f6VWSlnHGCE
** MySQL DBA Certification Training: https://www.edureka.co/mysql-dba **
This Edureka PPT on 'SQL Triggers' will help you understand the concept of triggers in SQL. Below are the topics covered in this SQL Triggers For Beginners.
Follow us to never miss an update in the future.
YouTube: https://www.youtube.com/user/edurekaIN
Instagram: https://www.instagram.com/edureka_learning/
Facebook: https://www.facebook.com/edurekaIN/
Twitter: https://twitter.com/edurekain
LinkedIn: https://www.linkedin.com/company/edureka
Castbox: https://castbox.fm/networks/505?country=in
Collections Framework is a unified architecture for managing collections, Main Parts of Collections Framework
1. Interfaces :- Core interfaces defining common functionality exhibited by collections
2. Implementations :- Concrete classes of the core interfaces providing data structures
3. Operations :- Methods that perform various operations on collections
Loops in Java. Looping in programming languages is a feature which facilitates the execution of a set of instructions/functions repeatedly while some condition evaluates to true.
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.
Oracle Analytical Function Include First Value, Last Value, Lead, Lag, Nth Value with Unbounded and Difference between Rank and Dense Rank . Contain Rollup, Cube and Grouping and Different type of Window Function and Analytical Window frame
Are you an Oracle developer or a DBA?
Do you know the difference between aggregate and analytic functions?
Without complex sub-queries or self-joins, do you know how to:
Calculate running/cumulative totals and moving/centered averages?
List products with revenues above or below their peers or product groups?
Compute the ratio of one category’s sales to the total sales?
Select the Top-N or Top N % of the customers/products?
Classify advertisers into quartiles/n-tiles based on the revenue potential?
Compare period-over-period (year-over-year, month-over-month) growth and rank advancement?
Convert rows into columns (pivot), columns into rows (unpivot) or aggregate strings?
Perform what-if analysis and hypothetical ranking?
Analytic functions are more performant because tables need to be scanned only once. They make you more productive because there is no need to write procedural code. No wonder Tom Kyte, a well-respected Oracle guru, says analytic functions are the best thing to happen after the sliced bread.
In the first half, I will cover the basics of the various analytic functions:
Ranking: RANK, DENSE_RANK, ROW_NUMBER, NTILE, CUME_DIST, PERCENTILE_RANK
Windowing: SUM, AVG, MAX, MIN, FIRST_VALUE, LAST_VALUE
Reporting: RATIO_TO_REPORT
Others: FIRST/LAST, LEAD/LAG, hypothetical ranking,
In the second half, I will show how powerful these functions are with a few examples.
If there is time, I will cover enhanced aggregation (ROLLUP, CUBE, GROUPING SET extensions to GROUP BY clause)
This class would be useful for both developers and DBAs alike, especially for those working in Analytic, Business Intelligence, and Datawarehouse environments.
Are you already an expert in analytic functions? Then come and help me refine the content.
For more info, read
http://download.oracle.com/docs/cd/E11882_01/server.112/e16579/analysis.htm
http://download.oracle.com/docs/cd/E11882_01/server.112/e16579/aggreg.htm
rollup, cross-tabulation across different dimensions using ROLLUP, CUBE and GROUPING SETS extension to GROUP BY clause
, most active time-periods (i.e. days when the most number of tickets are open in BZ, hours with the most take-off and landings, months with the highest sales, 5-minute periods with the maximum number of calls made, etc)
data densification?
their rank last year, this year, rank growth, running/cumulative total (Year-To-Date/Month-To-Date summation), moving averages, Year-Over-Year comparison, sales projection, average/min/max time between one sale and the next sale, products with above and below average sales.
overall average, sum, departmental average, sum, ranking, job wise ranking in one SQL.
Oracle Advanced SQL and Analytic FunctionsZohar Elkayam
Even though DBAs and developers are writing SQL queries every day, it seems that advanced SQL techniques such as multidimension aggregation and analytic functions still remain relatively unknown. In this session, we will explore some of the common real-world usages for analytic function and understand how to take advantage of this great and useful tool. We will deep dive into ranking based on values and groups, understand aggregation of multiple dimensions without a group by, see how to do inter-row calculations, and much more.
This is the presentation slides which was presented in Kscope 17 on June 28, 2017.
Explore how data science can be used to predict employee churn using this data science project presentation, allowing organizations to proactively address retention issues. This student presentation from Boston Institute of Analytics showcases the methodology, insights, and implications of predicting employee turnover. visit https://bostoninstituteofanalytics.org/data-science-and-artificial-intelligence/ for more data science insights
Our database experts, Rajnikant Tandel and Anup Gopinathan, will show you how to identify and fine tune your problem queries to make a significant impact on the overall performance of your database.
This session talks all about SQL Server Query Parameterization. Covers various topics like Query Tuning, Adhoc Query, Execution Plan, Query Optimizer, Parameter Sniffing, Indexes etc. etc.
Large Language Models and the End of ProgrammingMatt Welsh
Talk by Matt Welsh at Craft Conference 2024 on the impact that Large Language Models will have on the future of software development. In this talk, I discuss the ways in which LLMs will impact the software industry, from replacing human software developers with AI, to replacing conventional software with models that perform reasoning, computation, and problem-solving.
We describe the deployment and use of Globus Compute for remote computation. This content is aimed at researchers who wish to compute on remote resources using a unified programming interface, as well as system administrators who will deploy and operate Globus Compute services on their research computing infrastructure.
Globus Connect Server Deep Dive - GlobusWorld 2024Globus
We explore the Globus Connect Server (GCS) architecture and experiment with advanced configuration options and use cases. This content is targeted at system administrators who are familiar with GCS and currently operate—or are planning to operate—broader deployments at their institution.
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...Globus
The Earth System Grid Federation (ESGF) is a global network of data servers that archives and distributes the planet’s largest collection of Earth system model output for thousands of climate and environmental scientists worldwide. Many of these petabyte-scale data archives are located in proximity to large high-performance computing (HPC) or cloud computing resources, but the primary workflow for data users consists of transferring data, and applying computations on a different system. As a part of the ESGF 2.0 US project (funded by the United States Department of Energy Office of Science), we developed pre-defined data workflows, which can be run on-demand, capable of applying many data reduction and data analysis to the large ESGF data archives, transferring only the resultant analysis (ex. visualizations, smaller data files). In this talk, we will showcase a few of these workflows, highlighting how Globus Flows can be used for petabyte-scale climate analysis.
Check out the webinar slides to learn more about how XfilesPro transforms Salesforce document management by leveraging its world-class applications. For more details, please connect with sales@xfilespro.com
If you want to watch the on-demand webinar, please click here: https://www.xfilespro.com/webinars/salesforce-document-management-2-0-smarter-faster-better/
Navigating the Metaverse: A Journey into Virtual Evolution"Donna Lenk
Join us for an exploration of the Metaverse's evolution, where innovation meets imagination. Discover new dimensions of virtual events, engage with thought-provoking discussions, and witness the transformative power of digital realms."
Experience our free, in-depth three-part Tendenci Platform Corporate Membership Management workshop series! In Session 1 on May 14th, 2024, we began with an Introduction and Setup, mastering the configuration of your Corporate Membership Module settings to establish membership types, applications, and more. Then, on May 16th, 2024, in Session 2, we focused on binding individual members to a Corporate Membership and Corporate Reps, teaching you how to add individual members and assign Corporate Representatives to manage dues, renewals, and associated members. Finally, on May 28th, 2024, in Session 3, we covered questions and concerns, addressing any queries or issues you may have.
For more Tendenci AMS events, check out www.tendenci.com/events
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...Globus
The U.S. Geological Survey (USGS) has made substantial investments in meeting evolving scientific, technical, and policy driven demands on storing, managing, and delivering data. As these demands continue to grow in complexity and scale, the USGS must continue to explore innovative solutions to improve its management, curation, sharing, delivering, and preservation approaches for large-scale research data. Supporting these needs, the USGS has partnered with the University of Chicago-Globus to research and develop advanced repository components and workflows leveraging its current investment in Globus. The primary outcome of this partnership includes the development of a prototype enterprise repository, driven by USGS Data Release requirements, through exploration and implementation of the entire suite of the Globus platform offerings, including Globus Flow, Globus Auth, Globus Transfer, and Globus Search. This presentation will provide insights into this research partnership, introduce the unique requirements and challenges being addressed and provide relevant project progress.
Enhancing Project Management Efficiency_ Leveraging AI Tools like ChatGPT.pdfJay Das
With the advent of artificial intelligence or AI tools, project management processes are undergoing a transformative shift. By using tools like ChatGPT, and Bard organizations can empower their leaders and managers to plan, execute, and monitor projects more effectively.
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...Mind IT Systems
Healthcare providers often struggle with the complexities of chronic conditions and remote patient monitoring, as each patient requires personalized care and ongoing monitoring. Off-the-shelf solutions may not meet these diverse needs, leading to inefficiencies and gaps in care. It’s here, custom healthcare software offers a tailored solution, ensuring improved care and effectiveness.
Unleash Unlimited Potential with One-Time Purchase
BoxLang is more than just a language; it's a community. By choosing a Visionary License, you're not just investing in your success, you're actively contributing to the ongoing development and support of BoxLang.
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...Anthony Dahanne
Les Buildpacks existent depuis plus de 10 ans ! D’abord, ils étaient utilisés pour détecter et construire une application avant de la déployer sur certains PaaS. Ensuite, nous avons pu créer des images Docker (OCI) avec leur dernière génération, les Cloud Native Buildpacks (CNCF en incubation). Sont-ils une bonne alternative au Dockerfile ? Que sont les buildpacks Paketo ? Quelles communautés les soutiennent et comment ?
Venez le découvrir lors de cette session ignite
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...Juraj Vysvader
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I didn't get rich from it but it did have 63K downloads (powered possible tens of thousands of websites).
In software engineering, the right architecture is essential for robust, scalable platforms. Wix has undergone a pivotal shift from event sourcing to a CRUD-based model for its microservices. This talk will chart the course of this pivotal journey.
Event sourcing, which records state changes as immutable events, provided robust auditing and "time travel" debugging for Wix Stores' microservices. Despite its benefits, the complexity it introduced in state management slowed development. Wix responded by adopting a simpler, unified CRUD model. This talk will explore the challenges of event sourcing and the advantages of Wix's new "CRUD on steroids" approach, which streamlines API integration and domain event management while preserving data integrity and system resilience.
Participants will gain valuable insights into Wix's strategies for ensuring atomicity in database updates and event production, as well as caching, materialization, and performance optimization techniques within a distributed system.
Join us to discover how Wix has mastered the art of balancing simplicity and extensibility, and learn how the re-adoption of the modest CRUD has turbocharged their development velocity, resilience, and scalability in a high-growth environment.
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptxrickgrimesss22
Discover the essential features to incorporate in your Winzo clone app to boost business growth, enhance user engagement, and drive revenue. Learn how to create a compelling gaming experience that stands out in the competitive market.
Developing Distributed High-performance Computing Capabilities of an Open Sci...Globus
COVID-19 had an unprecedented impact on scientific collaboration. The pandemic and its broad response from the scientific community has forged new relationships among public health practitioners, mathematical modelers, and scientific computing specialists, while revealing critical gaps in exploiting advanced computing systems to support urgent decision making. Informed by our team’s work in applying high-performance computing in support of public health decision makers during the COVID-19 pandemic, we present how Globus technologies are enabling the development of an open science platform for robust epidemic analysis, with the goal of collaborative, secure, distributed, on-demand, and fast time-to-solution analyses to support public health.
4. Manipulating Data
Default Feature: In Oracle Data Definition Language (DDL) , we have the
ability to assign default values to columns in table.
Example - 1
Create table customer1 {
customer_id number,
customer_name varchar 2 (20),
exp_date date DEFAULT to_date (‘31-dec-2009’,’dd-mon-yyyy’) }
→ insert into customer1 (customer_id, customer_name) values (1,’Jones’);
→ insert into customer1 (customer_id,customer_name,exp_date) values
(2,’Raj’,’DEFAULT);
5. Virtual Column
● Virtual Columns appear just like your normal table columns, but their
values are derived at run time then being stored on disc.
● We cannot insert any data into a virtual column
Advantages:
● Saves Disk spaces
● Need not update data if formula changes.
6. Arithmetic calculations on Null
values
● Any arithmetic expression which involves a NULL value returns a
NULL value as the output.
● Use NVL functions while performing Arithmetic expression on NULL
values in a table.
7. Arithmetic calculations on Null
values
Example: DO
● select AVG (NVL(sales_amount,0)) from sales
● select COUNT (NVL(sales_amount,0)) from sales
Example : DON’T
● select AVG (sales_amount) FROM sales;
● select COUNT (sales_amount) from sales;
NULL values are not considered while taking Average or count, we have
to use NVL function to the average and count values having nulls.
8. Multi table Inserts
Oracle INSERT ALL statement is used to add multiple rows with a single
INSERT statement. The rows can be inserted into one table or multiple
tables using only one SQL command.
Inserting into 1 Table
INSERT ALL
INTO customer1 (customer_id,customer_name) values (1,’Kenny’)
INTO customer1 (customer_id,customer_name)values (2,’Peter’)
INTO customer1 (customer_id,customer_name)values (3,’John’)
select* from dual;
9. Multi table Inserts
Inserting into Multiple Tables
INSERT ALL
INTO customer1(customer_id,customer_name) VALUES (1,’Kenny’)
INTO customer1 (customer_id,customer_name) VALUES (2,’Peter’)
INTO sales1 (sales_date,order_id,total_amount) VALUES (‘12-Jan
-2017’,345,900);
10. Merge the Data
Merge statement is used to select rows from one or more sources for
update or insertion into table or view.
Merge Statement :-
1) Provides a convenient way to combine multiple operations.
2) Lets you avoid multiple INSERT,UPDATE and DELETE DML statement
If Match found – UPDATE
If Match not found – INSERT
MERGE statement with Conditions We can specify conditions to
determine whether to update or insert into target table or view.
11. Example of
Analytical Function
Simple Query:
Select sales_date, order_id,product_id,sales_amount,avg_amount from
sales, (select_avg(sales_amount) as avg_amount from sales)
Analytical Query:
Select sales_date, order_id,product_id,sales_amount,
avg(sales_amount) over () from sales
● In Analytical query (2nd ) we are fetching once and where as in 1st
query we are fetching data multiple times. So 1st query burden’s the
database.
12. Analytical Functions
Used to compute and aggregate values based on group of rows.
The group of rows is called a window and is defined by the
analytic_clause.
Advantages
a) Improve Query Speed
b) Enhanced Developer Productivity
c) Minimized Learning Effort
14. Rank Function
● The RANK function produces an ordered ranking of rows starting with
a rank of one.
● RANK function returns the rank of a value in a group of values.
● The RANK function can be used two ways - as an Aggregate function
or as an Analytic function.
15. Window Function:
● The GROUP BY clause allows us to apply aggregate functions to
subsets of rows.
● This time AVG is an analytic function, operating on the group of rows
defined by the contents of the OVER clause.
● This group of rows is known as a window, which is why analytic
functions are sometimes referred to as window[ing] functions.
16. LAG And LEAD Function
● LAG navigates back : Previous month, quarter , year
● LEAD navigates front: Next month, quarter , year
● These functions are used to analyse data over a period of time.
Example this month vs next month,last years vs this years,etc.
17. Reporting Function:
● After a query has been processed, aggregate values like the number
of resulting rows or an average value in a column can be easily
computed within a partition and made available to other reporting
functions.
● Reporting aggregate functions return the same aggregate value for
every row in a partition.
19. Case Statement
● Converting the row level data to column level using CASE statement.
● The CASE statement is like a series of IF statements, only using the
key word WHEN. A CASE statement is evaluated from top to bottom.
● If a condition is true, then corresponding THEN clause is executed
and execution jumps to the END CASE (short circuit evaluation)
clause.
21. PIVOT
● Converting the row level data to column level using PIVOT Analytical
function.
● PIVOT is faster than CASE statement.
● PIVOT means that you can aggregate your results and rotate rows
into columns.
22. PIVOT
Syntax:
Select * from (select column1, column2 from tables where
conditions)
PIVOT
aggregate_function(column2)
FOR column2
IN ( expr1, expr2, ... expr_n) | subquery)
ORDER BY expression [ ASC | DESC ];
23. PIVOT - Syntax
Parameters:
● aggregate_function: It can be a function such as SUM, COUNT, MIN,
MAX, or AVG functions.
● IN ( expr1, expr2, ... expr_n ): A list of values for column2 to pivot into
headings in the cross-tabulation query results.
● Subquery: It can be used instead of a list of values. In this case, the
results of the subquery would be used to determine the values for
column2 to pivot into headings in the cross-tabulation query results.
24. LISTAGG
● Converting the row level data to column level using LISTAGG Analytical
function.
● Group all the values and all values are displayed in a single column.
● The nice thing about this function is it also allows us to order the elements
in the concatenated list.
Syntax
LISTAGG (measure_column [, 'delimiter'])
WITHIN GROUP (order_by_clause) [OVER (query_partition_clause)]
25. LISTAGG - Syntax
Syntax Arguments:
● measure_column:The column or expression whose values you wish
to concatenate together in the result set. Null values in the
measure_column are ignored.
● Delimiter: Optional. It is the delimiter to use when separating the
measure_column values when outputting the results.
● order_by_clause: It determines the order that the concatenated
values (ie: measure_column) are returned.
26. UNION ALL
● Converting the column level data to row level using UNION ALL
● It returns all rows from the query and it does not remove duplicate
rows between the various SELECT statements.
● Each SELECT statement within the UNION ALL operator must have
the same number of fields in the result sets with similar data types.
27. UNION ALL
Syntax:
SELECT expression1, expression2, ... expression_n FROM tables
[WHERE conditions]
UNION ALL
SELECT expression1, expression2, ... expression_n
FROM tables [WHERE conditions];
28. UNPIVOT
● Converting the column level data to row level using
● UNPIVOT.UNPIVOT transposes columns in rows.
Example:
Create table # student
(Student Id int,Marks1 float,
Marks2 float, Marks3 float)
insert into #student
values (1,5.6,7.3,4.2)
insert values for all 4 rows.
29. UNPIVOT - Syntax
SELECT StudentID, MarksNo, MarksRecd
FROM
(SELECT StudentID,
Marks1, Marks2, Marks3
FROM #Student) stu
UNPIVOT
(MarksRecd FOR MarksNo
IN (Marks1, Marks2, Marks3))
AS marks
31. Hierarchical Query
● Hierarchical query needs a definition of how each child relates to its
parent.
● This is defined using the CONNECT BY .. PRIOR clause, which
defines how the current row (child) relates to a prior row (parent).
● The START WITH clause can be used to define the root node(s) of
the hierarchy.
32. Hierarchical Query -
Operators
● LEVEL : The position in the hierarchy of the current row in relation to
the root node.
● CONNECT_BY_ROOT : Returns the root node(s) associated with the
current row.
● SYS_CONNECT_BY_PATH : Returns a delimited breadcrumb from
root to the current row.
● CONNECT_BY_ISLEAF : Indicates if the current row is a leaf node.
● ORDER SIBLINGS BY : Applies an order to siblings, without altering
the basic hierarchical structure of the data returned by the query.
33. CONNECT BY,PRIOR &
START WITH
● The CONNECT BY clause specifies the relationship between parent
rows and child rows of the hierarchy.
● The connect_by_condition can be any condition, however, it must use
the PRIOR operator to refer to the parent row.
● Restriction on the CONNECT BY clause: The connect_by_condition
cannot contain a regular subquery or a scalar subquery expression.
34. CONNECT BY,PRIOR &
START WITH
Example:
SELECT employee_id, last_name, manager_id, LEVEL
FROM employees
CONNECT BY PRIOR employee_id = manager_id;
RESULT: Shows employee_id, last_name, manager_id and level in the
tree for the employee hierarchy.
35. CONNECT BY ROOT
● CONNECT_BY_ROOT is a unary operator that is valid only in
hierarchical queries.
● When you qualify a column with this operator, Oracle returns the
column value using data from the root row.
● This operator extends the functionality of the CONNECT BY [PRIOR]
condition of hierarchical queries.
● Restriction on CONNECT_BY_ROOT: You cannot specify this
operator in the START WITH condition or the CONNECT BY
condition
36. SYS-CONNECT_BY_PATH
● SYS_CONNECT_BY_PATH is valid only in hierarchical queries.
● It returns the path of a column value from root to node, with column
values separated by char for each row returned by CONNECT BY
condition.
37. Extension To GROUP BY
● Aggregation is a fundamental part of data warehousing.
● To improve aggregation performance in your warehouse, Oracle
Database provides the following extensions to the GROUP BY
clause:
– CUBE and ROLLUP extensions to the GROUP BY clause
– GROUPING functions
– GROUPING SETS expression
38. ROLLUP Extension to
GROUP BY
● ROLLUP enables a SELECT statement to calculate multiple levels of
subtotals across a specified group of dimensions.
● It also calculates a grand total.
● The ROLLUP extension is highly efficient, adding minimal overhead
to a query.
● The action of ROLLUP is straightforward: it creates subtotals that roll
up from the most detailed level to a grand total, following a grouping
list specified in the ROLLUP clause.
39. ROLLUP Extension to
GROUP BY
● First ,it calculates the standard aggregate values specified in the
GROUP BY clause.
● Then, it creates progressively higher-level subtotals, moving from
right to left through the list of grouping columns.
● Finally, it creates a grand total.
● If wanting to compress data when using ROLLUP. This is particularly
useful when there are few updates to older partitions.
40. WHEN TO USE ROLLUP
● Use the ROLLUP extension in tasks involving subtotals.
● It is very helpful for subtotaling along a hierarchical dimension such
as time or geography. For instance, a query could specify a
ROLLUP(y, m, day) or ROLLUP(country, state, city).
● For data warehouse administrators using summary tables, ROLLUP
can simplify and speed up the maintenance of summary tables.
Syntax:
ROLLUP appears in the GROUP BY clause in a SELECT statement. Its
form is:
SELECT … GROUP BY ROLLUP(grouping_column_reference_list)
41. CUBE Extension to GROUP BY
● CUBE takes a specified set of grouping columns and creates
subtotals for all of their possible combination.
● In terms of multidimensional
analysis, CUBE generates all
the subtotals that could be
calculated for a data cube with
the specified dimensions.
42. CUBE Extension to
GROUP BY
● The data needed for cross-tabular reports can be generated with a single
SELECT using CUBE.
● Note that population of summary tables is even faster if the CUBE query
executes in parallel.
● CUBE is typically most suitable in queries that use columns from multiple
dimensions rather than columns representing different levels of a single
dimension.
Syntax:
CUBE appears in the GROUP BY clause in a SELECT statement. Its form is:
SELECT … GROUP BY CUBE(grouping_column_reference_list)
43. Grouping Functions
● Two challenges arise with the use of ROLLUP and CUBE.
● How can you programmatically determine which result set rows are
subtotals, and how do you find the exact level of aggregation for a
given subtotal?
● What happens if query results contain both stored NULL values and
"NULL" values created by a ROLLUP or CUBE?
● GROUPING handles the above problems
44. When to use
GROUPING Function
● Using a single column as its argument, GROUPING returns 1 when it
encounters a NULL value created by a ROLLUP or CUBE operation.
● That is, if the NULL indicates the row is a subtotal, GROUPING
returns a 1. Any other type of value, including a stored NULL, returns
a 0.
● The GROUPING function is not only useful for identifying NULLs, it
also enables sorting subtotal rows and filtering results.
45. When to use
GROUPING Function
Syntax:
GROUPING appears in the selection list portion of a SELECT statement.
Its form is:
SELECT …
[GROUPING(dimension_column)…] …
GROUP BY …
{CUBE | ROLLUP| GROUPING SETS} (dimension_column)
46. Grouping Functions
● GROUPING_ID Function
● GROUPING SETS FUNCTION
Problem: A four-column GROUP BY clause needs to be analyzed with
four GROUPING functions. This is inconvenient to write in SQL and
increases the number of columns required in the query. When you want
to store the query result sets in tables, as with materialized views, the
extra columns waste storage space.
To address these problems, use the GROUPING_ID function
47. GROUPING_ID Functions
● GROUPING_ID returns a single number that enables you to
determine the exact GROUP BY level.
● For each row, GROUPING_ID takes the set of 1's and 0's that would
be generated if you used the appropriate GROUPING functions and
concatenates them, forming a bit vector.
● The bit vector is treated as a binary number, and the number's base-
10 value is returned by the GROUPING_ID function.
● If we group with the expression CUBE(a, b) the possible values:
48. GROUPING_ID
Example for CUBE(a, b)
Aggregation Level Bit Vector GROUPING_ID
a, b 0 0 0
a 0 1 1
b 1 0 2
Grand Total 1 1 3
GROUPING_ID clearly distinguishes groupings created by grouping set
specification, and it is very useful during refresh and rewrite of materialized
views.
49. GROUP_ID Function
● While the extensions to GROUP BY offer power and flexibility, they
also allow complex result sets that can include duplicate groupings.
● The GROUP_ID function lets you distinguish among duplicate
groupings.
● If there are multiple sets of rows calculated for a given level,
GROUP_ID assigns the value of 0 to all the rows in the first set.
● All other sets of duplicate rows for a particular grouping are assigned
higher values, starting with 1
50. GROUPING SETS Syntax
● GROUPING SETS syntax lets you define multiple groupings in the
same query.
● GROUP BY computes all the groupings specified and combines them
with UNION ALL.
GROUP BY GROUPING sets (channel_desc, calendar_month_desc,
country_id )
The above statement is equivalent to:
GROUP BY channel_desc UNION ALL
GROUP BY calendar_month_desc UNION ALL GROUP BY country_id
51. GROUPING SETS Statements and
Equivalent GROUP BY
GROUPING SETS Statement Equivalent GROUP BY Statement
GROUP BY GROUPING SETS(a, b, c) GROUP BY a UNION ALL GROUP BY b UNION ALL GROUP BY c
GROUP BY GROUPING SETS(a, b, (b, c)) GROUP BY a UNION ALL GROUP BY b UNION ALL GROUP BY b, c
GROUP BY GROUPING SETS((a, b, c)) GROUP BY a, b, c
GROUP BY GROUPING SETS(a, (b), ()) GROUP BY a UNION ALL GROUP BY b UNION ALL GROUP BY ()
GROUP BY GROUPING SETS(a, ROLLUP(b, c)) GROUP BY a UNION ALL GROUP BY ROLLUP(b, c)
52. GROUPING SETS Statements and
Equivalent GROUP BY
● A query based on UNION would need multiple scans of the base
table, sales.
● This could be very inefficient as fact tables will normally be huge.
● Using GROUPING SETS statements, all the groupings of interest are
available in the same query block.
53. Composite Columns
● A composite column is a collection of columns that are treated as a
unit during the computation of groupings. You specify the columns in
parentheses as in the following statement:
ROLLUP (year, (quarter, month), day)
● Here, (quarter, month) form a composite column and are treated as a
unit.
● Composite columns are useful in ROLLUP, CUBE, GROUPING
SETS, and concatenated groupings.
GROUP BY ROLLUP(a, (b, c))
● Here, (b, c) are treated as a unit and rollup will not be applied across
(b, c)
54. Concatenated Groupings
● Concatenated Groupings offer a concise way to generate useful
combinations of groupings.
● Concatenation of grouping sets is very helpful for these reasons:
– Ease of query development
● You need not enumerate all groupings manually.
– Use by applications
● Groupings specified with concatenated groupings yield the cross-
product of groupings from each grouping set.
57. What is Table Partitioning?
● Table Partitioning is a way to divide a large table into smaller, more
manageable parts without having to create separate tables for each
part. Data in a partitioned table is physically stored in groups of rows
called partitions and each partition can be accessed and maintained
separated.
● Partitioning allows tables and indexes to be partitioned into smaller,
more manageable units, providing database administrators with the
ability to pursue a "divide and conquer" approach to data
management.
58. Why Table Partitioning?
● Data is growing tremendously in organizations, storing millions of
data.
● Data is growing bigger and bigger.
● Breaking big table into multiple pieces.
● Dividing table into multiple pieces is called 'PARTIONING' With
partitioning, maintenance operations can be focused on particular
portions of tables.
59. Types of Partitioning
● Single Level Partitioning
– Range Partitioning
– Hash Partitioning
– List Partitioning
– Composite Partitioning
60. Range Partitioning
● Range Partitioning maps data to partitions based on ranges of
values of the partitioning key that you establish for each partition.
● A table that is partitioned by range is partitioned in such a way that
each partition contains rows for which the partitioning expression
value lies within a given range. Ranges should be contiguous but
not overlapping, and are defined using the VALUES LESS THAN
operator.
62. Hash Partitioning
● The hashing algorithm evenly distributes rows among partitions,
giving partitions approximately the same size.
● Hash Partitioning is also an easy-to-use alternative to range
partitioning, especially when the data to be partitioned is not historical
or has no obvious partitioning key.
● To partition a table using HASH partitioning, it is necessary to append
to the CREATE TABLE statement a PARTITION BY HASH (expr)
clause, where expr is an expression that returns an integer.
64. List Partitioning
● List partitioning enables you to explicitly control how rows map to
partitions by specifying a list of discrete values for the partitioning key
in the description for each partition.
● The advantage of list partitioning is that you can group and organize
unordered and unrelated sets of data in a natural way.
68. Materialized View
● It is a table segment whose content are periodically refreshed based
on a query, either against a local or remote table.
● A materialized view is a table on disk that contains the result set of a
query.
Advantange:
● Replication of data between sites.
● Improve Performance
69. Options for Creating
Materialized View
● Immediate - The materialized view is populated with data
immediately because the build method is immediate and it is
available for use by query rewrite.
– Create the materialized view and then populate it with data.
● Deffered - Specify DEFERRED to indicate that the materialized view
is to be populated by the next REFRESH operation.
– Create the materialized view definition but do not populate it with
data.
70. Types of Refresh
Fast Refresh:
● Refreshes by incrementally adding the new data that has been
inserted into the tables using direct path or from the materialized view
log. Have to create 'LOG'"
● Fast Refresh" means you update (or insert/delete) only the rows
which have been changed on master tables.
71. Types of Refresh
Complete Refresh:
● "Complete Refresh" means you truncate entire materialized view and
insert new data.
● When a complete refresh occurs the materialized view's defining
query is executed and the entire result set replaces the data currently
residing in the materialized view.
72. Types of Refresh
Force Refresh:
● FORCE REFRESH is combination of FAST refresh and COMPLETE
refresh
● Applies FAST refresh if possible; otherwise, it applies COMPLETE
refresh.
73. Options For Refresh
Triggered- On Commit
● Refresh occurs automatically when a transaction that modified one of
the materialized view's detail tables commits.
● This can be specified as long as the materialized view is fast
refreshable (in other words, not complex). The ON COMMIT privilege
is necessary to use this mode.
● Can be used with materialized views on single table aggregates and
materialized views containing joins only.
74. Options For Refresh
Triggered- On Commit
● The time required to complete the commit may be slightly longer than
usual. This is because the refresh operation is performed as part of
the commit process.
● Therefore, this method may not be suitable if many users are
concurrently changing the tables upon which the materialized view is
based.
75. Options For Refresh
Triggered- On Demand
● The refresh is initiated by a manual request or a scheduled task.
● Refresh occurs when a user manually executes one of the available
refresh procedures contained in the DBMS_MVIEW package.
76. Options For Refresh
Triggered- On Demand
● Selecting the ON DEMAND execution mode means that you can take
advantage of the materialized view warehouse refresh facility, which
provides a quick and efficient mechanism for refreshing your
materialized views, either in their entirety or only with the additions to
the detail data.
● Oracle recommends you use ON COMMIT fast refresh rather than
ON DEMAND fast refresh.
78. Regular Expression
Regular expressions enable you to search for patterns in string data by
using standardized syntax conventions.
Types of Characters:
● Metacharacters : Operators that specify search algorithms.
● Literals : Characters for which you are searching
79. Regular Expression
SQL Regular Expression- Functions and Conditions
● REGEXP_LIKE ---> Condition
● REGEXP_REPLACE ---> Function
● REGEXP_INSTR ---> Function
● REGEXP_SUBSTR ---> Function
80. SQL -REGEXP
● REGEXP_LIKE : REGEXP_LIKE condition allows you to perform
regular expression matching in the WHERE clause of a SELECT,
INSERT, UPDATE, or DELETE statement.
● REGEXP_REPLACE: REGEXP_REPLACE function is an extension
of the REPLACE function. This will allow to replace a sequence of
characters in a string with another set of characters using regular
expression pattern matching.
81. SQL -REGEXP
● REGEXP_INSTR : REGEXP_INSTR function is an extension of the
INSTR function. It returns the location of a regular expression pattern
in a string. Allows to find a substring in a string using regular
expression pattern matching.
● REGEXP_SUBSTR: REGEXP_SUBSTR function is an extension of
the SUBSTR function. This allows to extract a substring from a string
using regular expression pattern matching.
84. Time Stamp
● It is useful to recover from accidental statement failures.
● Flashback feature depends upon on how much undo retention time
you have specified.
Example:
SQL>select * from emp as of timestamp sysdate-1/24;
Or
SQL> SELECT * FROM emp AS OF TIMESTAMP
TO_TIMESTAMP('2007-06-07 10:00:00', 'YYYY-MM-DD
HH:MI:SS')
85. Undo- Retention
● Flashback feature depends upon on how much undo retention time you
have specifies
Example:
To insert the accidentally deleted rows again in the table type
SQL
insert into emp (select * from emp as of timestamp sysdate-1/24)