SlideShare a Scribd company logo
1 of 37
Oracle Tips & Tricks  Feb 10, 2011 Shane Zhang
AGENDA ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
CASE Statement vs. Decode  ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
ANSI Standard Join Syntax ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Join Operators ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Join Operators Cont’d ,[object Object],[object Object],[object Object],[object Object],[object Object]
New in 9i - Full Outer Joins ,[object Object],[object Object],[object Object],[object Object],[object Object]
Self Joins ,[object Object],[object Object],[object Object],[object Object]
Renaming – Columns, Constraints, Tables ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Top N Analysis ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Windowing Function ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Traverse the Hierarchical tree ,[object Object],[object Object],[object Object],[object Object],[object Object],Does JONES have any authority over BLAKE?“ SELECT *  FROM employee WHERE lname = 'BLAKE' START WITH lname = 'JONES' CONNECT BY manager_emp_id = PRIOR emp_id;
XML ,[object Object],[object Object],[object Object],[object Object]
Using subquery ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Using subquery – Cont’d ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
With Clause ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Having Clause ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Oracle 9i – TIMESTAMP Data Type ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Information of a table ,[object Object],[object Object],[object Object],[object Object]
Information on Space ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Group By Enhancements – Grouping Set select count(*) CNT, deptno, 'summary' as job from emp group by deptno UNION ALL select count(*), deptno, job from emp group by deptno, job / CNT  DEPTNO JOB --- ---------- --------- 3  10 Summary 1  10 PRESIDENT 1  10 MANAGER 1  10 CLERK 5  20 Summary 1  20 MANAGER 2  20 CLERK 2  20 ANALYST 6  30 Summary 4  30 SALESMAN 1  30 MANAGER 1  30 CLERK select count(*) CNT, deptno , CASE GROUPING_ID(job) WHEN 1 THEN 'Summary' ELSE job END AS job from emp group by GROUPING SETS ( (deptno) , (deptno, job ) ) / CNT  DEPTNO JOB --- ---------- --------- 3  10 Summary 1  10 PRESIDENT 1  10 MANAGER 1  10 CLERK 5  20 Summary 1  20 MANAGER 2  20 CLERK 2  20 ANALYST 6  30 Summary 4  30 SALESMAN 1  30 MANAGER 1  30 CLERK Union all method,  multiple table scan , slow New method, fast
Group By Enhancements – ROLLUP / CUBE ,[object Object],[object Object],[object Object]
ROLLUP Example Query ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
ROLLUP Example Output SHP_RCV_SRC_CD TNDR_TYPE_CD SUM(A.NBR_OF_PKGS) SUM(A.NET_REV) SUM(A.RATD_WGT) 3 CCC 15204 452297 76297 3 DRPF 688169 12653173 3509281 3 SOLD 570572 8422926 3112950 3 ? 1273945 21528396 6698529 4 CCC 26 1414 100 4 DRPF 484 28301 4350 4 SOLD 759 23706 5306 4 ? 1269 53421 9756 5 CCC 18 975 80 5 DRPF 2123 101847 12510 5 SOLD 230 7026 1625 5 ? 2371 109849 14215 ? ? 1277585 21691666 6722500
CUBE Example Query  ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
CUBE Example Output SHP_RCV_SRC_CD TNDR_TYPE_CD SUM(A.NBR_OF_PKGS) SUM(A.NET_REV) SUM(A.RATD_WGT) 3 CCC 15204 452297 76297 3 DRPF 688169 12653173 3509281 3 SOLD 570572 8422926 3112950 3 ? 1273945 21528396 6698529 4 CCC 26 1414 100 4 DRPF 484 28301 4350 4 SOLD 759 23706 5306 4 ? 1269 53421 9756 5 CCC 18 975 80 5 DRPF 2123 101847 12510 5 SOLD 230 7026 1625 5 ? 2371 109849 14215 ? CCC 15248 454686 76478 ? DRPF 690776 12783322 3526141 ? SOLD 571561 8453658 3119881 ? ? 1277585 21691666 6722500
MERGE ,[object Object],[object Object],[object Object],[object Object],[object Object]
MERGE Cont’d ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
MERGE Cont’d  ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
MERGE Cont’d ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Skip Scanning of Indexes ,[object Object],[object Object],[object Object],[object Object],[object Object]
Index Compression  ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
All my Indexes should be compressed, right?  ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Temporary Tables ,[object Object],[object Object],[object Object],[object Object],[object Object]
Temporary Table Cont’d ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Temporary Table Cont’d ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Temporary Table Cont’d ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]

More Related Content

What's hot

The MySQL Query Optimizer Explained Through Optimizer Trace
The MySQL Query Optimizer Explained Through Optimizer TraceThe MySQL Query Optimizer Explained Through Optimizer Trace
The MySQL Query Optimizer Explained Through Optimizer Traceoysteing
 
Oracle 9i notes(kamal.love@gmail.com)
Oracle 9i  notes(kamal.love@gmail.com)Oracle 9i  notes(kamal.love@gmail.com)
Oracle 9i notes(kamal.love@gmail.com)Kamal Raj
 
Oracle - Program with PL/SQL - Lession 03
Oracle - Program with PL/SQL - Lession 03Oracle - Program with PL/SQL - Lession 03
Oracle - Program with PL/SQL - Lession 03Thuan Nguyen
 
Oracle - Program with PL/SQL - Lession 07
Oracle - Program with PL/SQL - Lession 07Oracle - Program with PL/SQL - Lession 07
Oracle - Program with PL/SQL - Lession 07Thuan Nguyen
 
Myth busters - performance tuning 101 2007
Myth busters - performance tuning 101 2007Myth busters - performance tuning 101 2007
Myth busters - performance tuning 101 2007paulguerin
 
MERGE SQL Statement: Lesser Known Facets
MERGE SQL Statement: Lesser Known FacetsMERGE SQL Statement: Lesser Known Facets
MERGE SQL Statement: Lesser Known FacetsAndrej Pashchenko
 

What's hot (20)

Single row functions
Single row functionsSingle row functions
Single row functions
 
Trig
TrigTrig
Trig
 
Les02
Les02Les02
Les02
 
SAS ODS HTML
SAS ODS HTMLSAS ODS HTML
SAS ODS HTML
 
Les01
Les01Les01
Les01
 
Les12 creating views
Les12 creating viewsLes12 creating views
Les12 creating views
 
Les04 Displaying Data From Multiple Table
Les04 Displaying Data From Multiple TableLes04 Displaying Data From Multiple Table
Les04 Displaying Data From Multiple Table
 
The MySQL Query Optimizer Explained Through Optimizer Trace
The MySQL Query Optimizer Explained Through Optimizer TraceThe MySQL Query Optimizer Explained Through Optimizer Trace
The MySQL Query Optimizer Explained Through Optimizer Trace
 
Les05 Aggregating Data Using Group Function
Les05 Aggregating Data Using Group FunctionLes05 Aggregating Data Using Group Function
Les05 Aggregating Data Using Group Function
 
Les10
Les10Les10
Les10
 
Oracle 9i notes(kamal.love@gmail.com)
Oracle 9i  notes(kamal.love@gmail.com)Oracle 9i  notes(kamal.love@gmail.com)
Oracle 9i notes(kamal.love@gmail.com)
 
Les00 Intoduction
Les00 IntoductionLes00 Intoduction
Les00 Intoduction
 
Oracle - Program with PL/SQL - Lession 03
Oracle - Program with PL/SQL - Lession 03Oracle - Program with PL/SQL - Lession 03
Oracle - Program with PL/SQL - Lession 03
 
Les01 Writing Basic Sql Statements
Les01 Writing Basic Sql StatementsLes01 Writing Basic Sql Statements
Les01 Writing Basic Sql Statements
 
Les06 Subqueries
Les06 SubqueriesLes06 Subqueries
Les06 Subqueries
 
Oracle - Program with PL/SQL - Lession 07
Oracle - Program with PL/SQL - Lession 07Oracle - Program with PL/SQL - Lession 07
Oracle - Program with PL/SQL - Lession 07
 
Myth busters - performance tuning 101 2007
Myth busters - performance tuning 101 2007Myth busters - performance tuning 101 2007
Myth busters - performance tuning 101 2007
 
Excel Conditional Formatting
Excel Conditional Formatting Excel Conditional Formatting
Excel Conditional Formatting
 
MERGE SQL Statement: Lesser Known Facets
MERGE SQL Statement: Lesser Known FacetsMERGE SQL Statement: Lesser Known Facets
MERGE SQL Statement: Lesser Known Facets
 
Les02 Restricting And Sorting Data
Les02 Restricting And Sorting DataLes02 Restricting And Sorting Data
Les02 Restricting And Sorting Data
 

Viewers also liked

Oracle SQL Developer Top 10 Tips & Tricks
Oracle SQL Developer Top 10 Tips & TricksOracle SQL Developer Top 10 Tips & Tricks
Oracle SQL Developer Top 10 Tips & TricksJeff Smith
 
Oracle R12 EBS Performance Tuning
Oracle R12 EBS Performance TuningOracle R12 EBS Performance Tuning
Oracle R12 EBS Performance TuningScott Jenner
 
Oracle applications sla r12 SLA- demos
Oracle applications sla r12   SLA- demosOracle applications sla r12   SLA- demos
Oracle applications sla r12 SLA- demosAli Ibrahim
 
Seminario de evangelizacao italia 2012
Seminario de evangelizacao italia 2012Seminario de evangelizacao italia 2012
Seminario de evangelizacao italia 2012Arlete Laenzlinger
 
sheila, marta,estela eta adur
sheila, marta,estela eta adursheila, marta,estela eta adur
sheila, marta,estela eta adursheila1033
 
Sadarah 5th-022.. ملامح قيادية عند الحيوان.. عرض
Sadarah 5th-022.. ملامح قيادية عند الحيوان.. عرضSadarah 5th-022.. ملامح قيادية عند الحيوان.. عرض
Sadarah 5th-022.. ملامح قيادية عند الحيوان.. عرضAbdullah Ali
 
Duminica I din Post
Duminica I din PostDuminica I din Post
Duminica I din PostRadu Capan
 
خوارزميات صدارة.. الجودة في التسويق.. مختصر العرض.. عرض
خوارزميات صدارة.. الجودة في التسويق.. مختصر العرض.. عرضخوارزميات صدارة.. الجودة في التسويق.. مختصر العرض.. عرض
خوارزميات صدارة.. الجودة في التسويق.. مختصر العرض.. عرضAbdullah Ali
 
‫Sadarah pmp-001.. المقدمة والتفسيرات.. عرض
‫Sadarah pmp-001.. المقدمة والتفسيرات.. عرض‫Sadarah pmp-001.. المقدمة والتفسيرات.. عرض
‫Sadarah pmp-001.. المقدمة والتفسيرات.. عرضAbdullah Ali
 
Sadarah 5th-030.. 5 أسئلة لتحديد العملاء.. عرض
Sadarah 5th-030.. 5 أسئلة لتحديد العملاء.. عرضSadarah 5th-030.. 5 أسئلة لتحديد العملاء.. عرض
Sadarah 5th-030.. 5 أسئلة لتحديد العملاء.. عرضAbdullah Ali
 
Land Investments Expo 2014, KICC Nairobi Kenya
Land Investments Expo 2014, KICC Nairobi KenyaLand Investments Expo 2014, KICC Nairobi Kenya
Land Investments Expo 2014, KICC Nairobi KenyaSam Morara
 

Viewers also liked (20)

Oracle SQL Developer Top 10 Tips & Tricks
Oracle SQL Developer Top 10 Tips & TricksOracle SQL Developer Top 10 Tips & Tricks
Oracle SQL Developer Top 10 Tips & Tricks
 
Oracle R12 EBS Performance Tuning
Oracle R12 EBS Performance TuningOracle R12 EBS Performance Tuning
Oracle R12 EBS Performance Tuning
 
Supporting References in Oracle EBS R12
Supporting References in Oracle EBS R12Supporting References in Oracle EBS R12
Supporting References in Oracle EBS R12
 
Oracle applications sla r12 SLA- demos
Oracle applications sla r12   SLA- demosOracle applications sla r12   SLA- demos
Oracle applications sla r12 SLA- demos
 
Sla and cost acctg
Sla and cost acctgSla and cost acctg
Sla and cost acctg
 
FBLA-PBL History: Celebrating 70 Years!
FBLA-PBL History: Celebrating 70 Years!FBLA-PBL History: Celebrating 70 Years!
FBLA-PBL History: Celebrating 70 Years!
 
Seminario de evangelizacao italia 2012
Seminario de evangelizacao italia 2012Seminario de evangelizacao italia 2012
Seminario de evangelizacao italia 2012
 
sheila, marta,estela eta adur
sheila, marta,estela eta adursheila, marta,estela eta adur
sheila, marta,estela eta adur
 
Sadarah 5th-022.. ملامح قيادية عند الحيوان.. عرض
Sadarah 5th-022.. ملامح قيادية عند الحيوان.. عرضSadarah 5th-022.. ملامح قيادية عند الحيوان.. عرض
Sadarah 5th-022.. ملامح قيادية عند الحيوان.. عرض
 
Duminica I din Post
Duminica I din PostDuminica I din Post
Duminica I din Post
 
خوارزميات صدارة.. الجودة في التسويق.. مختصر العرض.. عرض
خوارزميات صدارة.. الجودة في التسويق.. مختصر العرض.. عرضخوارزميات صدارة.. الجودة في التسويق.. مختصر العرض.. عرض
خوارزميات صدارة.. الجودة في التسويق.. مختصر العرض.. عرض
 
SC
SCSC
SC
 
‫Sadarah pmp-001.. المقدمة والتفسيرات.. عرض
‫Sadarah pmp-001.. المقدمة والتفسيرات.. عرض‫Sadarah pmp-001.. المقدمة والتفسيرات.. عرض
‫Sadarah pmp-001.. المقدمة والتفسيرات.. عرض
 
Sadarah 5th-030.. 5 أسئلة لتحديد العملاء.. عرض
Sadarah 5th-030.. 5 أسئلة لتحديد العملاء.. عرضSadarah 5th-030.. 5 أسئلة لتحديد العملاء.. عرض
Sadarah 5th-030.. 5 أسئلة لتحديد العملاء.. عرض
 
Land Investments Expo 2014, KICC Nairobi Kenya
Land Investments Expo 2014, KICC Nairobi KenyaLand Investments Expo 2014, KICC Nairobi Kenya
Land Investments Expo 2014, KICC Nairobi Kenya
 
StartUp Sussex - Application Form June 2013
StartUp Sussex - Application Form June 2013StartUp Sussex - Application Form June 2013
StartUp Sussex - Application Form June 2013
 
Ghost Executive Group
Ghost Executive GroupGhost Executive Group
Ghost Executive Group
 
International Student Briefing - Effective Job Search Strategies
International Student Briefing - Effective Job Search StrategiesInternational Student Briefing - Effective Job Search Strategies
International Student Briefing - Effective Job Search Strategies
 
Azresidentialpropertiesinc management-5-6-2012
Azresidentialpropertiesinc management-5-6-2012Azresidentialpropertiesinc management-5-6-2012
Azresidentialpropertiesinc management-5-6-2012
 
Routes into Teaching 2016-17
Routes into Teaching 2016-17Routes into Teaching 2016-17
Routes into Teaching 2016-17
 

Similar to Oracle tips and tricks for joins, CASE statements, and more

Similar to Oracle tips and tricks for joins, CASE statements, and more (20)

Aggregate Functions,Final
Aggregate Functions,FinalAggregate Functions,Final
Aggregate Functions,Final
 
Oracle sql tuning
Oracle sql tuningOracle sql tuning
Oracle sql tuning
 
Chapter08
Chapter08Chapter08
Chapter08
 
Sql query [select, sub] 4
Sql query [select, sub] 4Sql query [select, sub] 4
Sql query [select, sub] 4
 
Oracle - Program with PL/SQL - Lession 09
Oracle - Program with PL/SQL - Lession 09Oracle - Program with PL/SQL - Lession 09
Oracle - Program with PL/SQL - Lession 09
 
SQL Notes
SQL NotesSQL Notes
SQL Notes
 
Beginers guide for oracle sql
Beginers guide for oracle sqlBeginers guide for oracle sql
Beginers guide for oracle sql
 
Introduction to Oracle Functions--(SQL)--Abhishek Sharma
Introduction to Oracle Functions--(SQL)--Abhishek SharmaIntroduction to Oracle Functions--(SQL)--Abhishek Sharma
Introduction to Oracle Functions--(SQL)--Abhishek Sharma
 
Sql dml & tcl 2
Sql   dml & tcl 2Sql   dml & tcl 2
Sql dml & tcl 2
 
Ctes percona live_2017
Ctes percona live_2017Ctes percona live_2017
Ctes percona live_2017
 
Introduction to oracle functions
Introduction to oracle functionsIntroduction to oracle functions
Introduction to oracle functions
 
Oracle
OracleOracle
Oracle
 
Database development coding standards
Database development coding standardsDatabase development coding standards
Database development coding standards
 
Oracle Training in Kochi | Trivandrum |Thrissur
Oracle Training in Kochi | Trivandrum |ThrissurOracle Training in Kochi | Trivandrum |Thrissur
Oracle Training in Kochi | Trivandrum |Thrissur
 
Chinabankppt
ChinabankpptChinabankppt
Chinabankppt
 
Sql
SqlSql
Sql
 
Complex Queries using MYSQL00123211.pptx
Complex Queries using MYSQL00123211.pptxComplex Queries using MYSQL00123211.pptx
Complex Queries using MYSQL00123211.pptx
 
Select To Order By
Select  To  Order BySelect  To  Order By
Select To Order By
 
Business Intelligence Portfolio
Business Intelligence PortfolioBusiness Intelligence Portfolio
Business Intelligence Portfolio
 
My SQL.pptx
My SQL.pptxMy SQL.pptx
My SQL.pptx
 

More from Yanli Liu

Business English
Business EnglishBusiness English
Business EnglishYanli Liu
 
China History and Today
China History and TodayChina History and Today
China History and TodayYanli Liu
 
Air Cargo 101
Air Cargo 101Air Cargo 101
Air Cargo 101Yanli Liu
 
Blue Ocean Strategy
Blue Ocean StrategyBlue Ocean Strategy
Blue Ocean StrategyYanli Liu
 
The World Is Flat
The World Is FlatThe World Is Flat
The World Is FlatYanli Liu
 

More from Yanli Liu (9)

Business English
Business EnglishBusiness English
Business English
 
SAS Notes
SAS NotesSAS Notes
SAS Notes
 
China History and Today
China History and TodayChina History and Today
China History and Today
 
Air Cargo 101
Air Cargo 101Air Cargo 101
Air Cargo 101
 
Finance 101
Finance 101Finance 101
Finance 101
 
Blackswan
BlackswanBlackswan
Blackswan
 
Peak Oil
Peak OilPeak Oil
Peak Oil
 
Blue Ocean Strategy
Blue Ocean StrategyBlue Ocean Strategy
Blue Ocean Strategy
 
The World Is Flat
The World Is FlatThe World Is Flat
The World Is Flat
 

Recently uploaded

TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 

Recently uploaded (20)

TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 

Oracle tips and tricks for joins, CASE statements, and more

  • 1. Oracle Tips & Tricks Feb 10, 2011 Shane Zhang
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
  • 21. Group By Enhancements – Grouping Set select count(*) CNT, deptno, 'summary' as job from emp group by deptno UNION ALL select count(*), deptno, job from emp group by deptno, job / CNT DEPTNO JOB --- ---------- --------- 3 10 Summary 1 10 PRESIDENT 1 10 MANAGER 1 10 CLERK 5 20 Summary 1 20 MANAGER 2 20 CLERK 2 20 ANALYST 6 30 Summary 4 30 SALESMAN 1 30 MANAGER 1 30 CLERK select count(*) CNT, deptno , CASE GROUPING_ID(job) WHEN 1 THEN 'Summary' ELSE job END AS job from emp group by GROUPING SETS ( (deptno) , (deptno, job ) ) / CNT DEPTNO JOB --- ---------- --------- 3 10 Summary 1 10 PRESIDENT 1 10 MANAGER 1 10 CLERK 5 20 Summary 1 20 MANAGER 2 20 CLERK 2 20 ANALYST 6 30 Summary 4 30 SALESMAN 1 30 MANAGER 1 30 CLERK Union all method, multiple table scan , slow New method, fast
  • 22.
  • 23.
  • 24. ROLLUP Example Output SHP_RCV_SRC_CD TNDR_TYPE_CD SUM(A.NBR_OF_PKGS) SUM(A.NET_REV) SUM(A.RATD_WGT) 3 CCC 15204 452297 76297 3 DRPF 688169 12653173 3509281 3 SOLD 570572 8422926 3112950 3 ? 1273945 21528396 6698529 4 CCC 26 1414 100 4 DRPF 484 28301 4350 4 SOLD 759 23706 5306 4 ? 1269 53421 9756 5 CCC 18 975 80 5 DRPF 2123 101847 12510 5 SOLD 230 7026 1625 5 ? 2371 109849 14215 ? ? 1277585 21691666 6722500
  • 25.
  • 26. CUBE Example Output SHP_RCV_SRC_CD TNDR_TYPE_CD SUM(A.NBR_OF_PKGS) SUM(A.NET_REV) SUM(A.RATD_WGT) 3 CCC 15204 452297 76297 3 DRPF 688169 12653173 3509281 3 SOLD 570572 8422926 3112950 3 ? 1273945 21528396 6698529 4 CCC 26 1414 100 4 DRPF 484 28301 4350 4 SOLD 759 23706 5306 4 ? 1269 53421 9756 5 CCC 18 975 80 5 DRPF 2123 101847 12510 5 SOLD 230 7026 1625 5 ? 2371 109849 14215 ? CCC 15248 454686 76478 ? DRPF 690776 12783322 3526141 ? SOLD 571561 8453658 3119881 ? ? 1277585 21691666 6722500
  • 27.
  • 28.
  • 29.
  • 30.
  • 31.
  • 32.
  • 33.
  • 34.
  • 35.
  • 36.
  • 37.