SlideShare a Scribd company logo
Yes, I demonstrated this in 2013 at Coder’s Corner, but I’ve
learned more
Bryan L. Mack
04/15/2016
Pivoting Data
Pivot Options –
sys_connect_by_path
Cumbersome, but it works with no sequence number.
Still – too lengthy for my taste.
Pivot Options – max(decode(
When you have a sequence number
 If no sequence exists, you can create one in-line
 You need to know how many entries exist
 May need to rtrim the final delimiter or do a REPLACE on extra delimiters
ListAgg
Source: http://docs.oracle.com
Why use ListAgg?
 Dynamic (knows how many rows exist in a group, so is
superior to using MAX(DECODE(<seq#
 Can use any delimiter you’d like
 Can concatenate multiple fields
 Simplistic code
ListAgg Syntax – Required
Components
Required Components
 Column(s) to be aggregated
 The WITHIN GROUP keywords
 The ORDER BY clause within the grouping
GROUP BY must be used for the entire block
Example #1
Example #2 – Repeated Values
Example #2 – 2 ways to get rid of
duplicates
Option #1 – create distinct data set and pull from it:
Example #2 – 2 ways to get rid of
duplicates
 Option #2 – Use Regular Expressions
Side note:
If using the RegExp method and your delimiter is not
“comma space” (‘, ‘) – then replace the three “, “
references on the 4th line of code with your delimiter.
Here is an example with a colon and no space:
Function to do this for you
create or replace function distinct_listagg
(listagg_in varchar2,
delimiter_in varchar2)
return varchar2
as
hold_result varchar2(4000);
begin
select rtrim( regexp_replace( (listagg_in)
, '([^'||delimiter_in||']*)('||
delimiter_in||'1)+($|'||delimiter_in||')', '13'), ',')
into hold_result
from dual;
return hold_result;
end;
Function to do this for you
 Example: The listagg function as such:
 listagg(ia.mif_value,',') within GROUP (ORDER
BY ia.person_uid, ia.academic_period)
 Returns: CCA,CCA,CCA,CCD,CCD,CCD,CCD

 Example using my function:
 distinct_listagg(listagg(ia.mif_value,',') within GROUP
(ORDER BY ia.person_uid, ia.academic_period),
 ',')
 Returns: CCA,CCD
Questions?
fleetmack@gmail.com

More Related Content

What's hot

Basics of Oracle Order Management
Basics of Oracle Order ManagementBasics of Oracle Order Management
Basics of Oracle Order Management
shravan kumar chelika
 
Ms sql-server
Ms sql-serverMs sql-server
Ms sql-server
Md.Mojibul Hoque
 
Oracle Advanced Procurement Training@ERP OCEAN
Oracle Advanced Procurement Training@ERP OCEANOracle Advanced Procurement Training@ERP OCEAN
Oracle Advanced Procurement Training@ERP OCEAN
ERP OCEAN Infotech Pvt Ltd
 
oracle order management
oracle order managementoracle order management
oracle order management
Souvik Chakraborty
 
Inventory in Oracle apps
Inventory in Oracle apps Inventory in Oracle apps
Inventory in Oracle apps
gbalagee
 
Oracle report from ppt
Oracle report from pptOracle report from ppt
Oracle report from ppt
kingshuk_goswami
 
Oracle Order Management - Order to Cash Cycle (O2C) - Data Flow
Oracle Order Management - Order to Cash Cycle (O2C) - Data FlowOracle Order Management - Order to Cash Cycle (O2C) - Data Flow
Oracle Order Management - Order to Cash Cycle (O2C) - Data Flow
Boopathy CS
 
Oracle Inventory - Working with Stock Locator
Oracle Inventory - Working with Stock LocatorOracle Inventory - Working with Stock Locator
Oracle Inventory - Working with Stock Locator
Rahul Guhathakurta
 
SOQL & SOSL for Admins
SOQL & SOSL for AdminsSOQL & SOSL for Admins
SOQL & SOSL for Admins
Obidjon Komiljonov
 
Oracle - SQL-PL/SQL context switching
Oracle - SQL-PL/SQL context switchingOracle - SQL-PL/SQL context switching
Oracle - SQL-PL/SQL context switching
Smitha Padmanabhan
 
Data Visualization Techniques in Power BI
Data Visualization Techniques in Power BIData Visualization Techniques in Power BI
Data Visualization Techniques in Power BI
Angel Abundez
 
Blanket purchase agreement and blanket release in oracle r12
Blanket purchase agreement and blanket release in oracle r12Blanket purchase agreement and blanket release in oracle r12
Blanket purchase agreement and blanket release in oracle r12
G Madhusudhan
 
Oracle Receivables ivas
Oracle Receivables ivasOracle Receivables ivas
Oracle Receivables ivas
Ali Ibrahim
 
Oracle R12 iProcurement Reference Guide
Oracle R12 iProcurement Reference GuideOracle R12 iProcurement Reference Guide
Oracle R12 iProcurement Reference Guide
Baker Khader Abdallah, PMP
 
Creating xml publisher documents with people code
Creating xml publisher documents with people codeCreating xml publisher documents with people code
Creating xml publisher documents with people codeRandall Groncki
 
Consignment inventory
Consignment inventoryConsignment inventory
Consignment inventory
Anubhav Mittal
 
5 enterprise structures
5   enterprise structures5   enterprise structures
5 enterprise structures
mohamed refaei
 
Auto lock box
Auto lock boxAuto lock box
Auto lock box
Madhurima Chatterjee
 

What's hot (20)

Basics of Oracle Order Management
Basics of Oracle Order ManagementBasics of Oracle Order Management
Basics of Oracle Order Management
 
Ms sql-server
Ms sql-serverMs sql-server
Ms sql-server
 
Oracle Advanced Procurement Training@ERP OCEAN
Oracle Advanced Procurement Training@ERP OCEANOracle Advanced Procurement Training@ERP OCEAN
Oracle Advanced Procurement Training@ERP OCEAN
 
oracle order management
oracle order managementoracle order management
oracle order management
 
Inventory in Oracle apps
Inventory in Oracle apps Inventory in Oracle apps
Inventory in Oracle apps
 
Oracle report from ppt
Oracle report from pptOracle report from ppt
Oracle report from ppt
 
Oracle i procurement
Oracle i procurementOracle i procurement
Oracle i procurement
 
Oracle Order Management - Order to Cash Cycle (O2C) - Data Flow
Oracle Order Management - Order to Cash Cycle (O2C) - Data FlowOracle Order Management - Order to Cash Cycle (O2C) - Data Flow
Oracle Order Management - Order to Cash Cycle (O2C) - Data Flow
 
Oracle Inventory - Working with Stock Locator
Oracle Inventory - Working with Stock LocatorOracle Inventory - Working with Stock Locator
Oracle Inventory - Working with Stock Locator
 
Order to Cash O2C Training
Order to Cash O2C TrainingOrder to Cash O2C Training
Order to Cash O2C Training
 
SOQL & SOSL for Admins
SOQL & SOSL for AdminsSOQL & SOSL for Admins
SOQL & SOSL for Admins
 
Oracle - SQL-PL/SQL context switching
Oracle - SQL-PL/SQL context switchingOracle - SQL-PL/SQL context switching
Oracle - SQL-PL/SQL context switching
 
Data Visualization Techniques in Power BI
Data Visualization Techniques in Power BIData Visualization Techniques in Power BI
Data Visualization Techniques in Power BI
 
Blanket purchase agreement and blanket release in oracle r12
Blanket purchase agreement and blanket release in oracle r12Blanket purchase agreement and blanket release in oracle r12
Blanket purchase agreement and blanket release in oracle r12
 
Oracle Receivables ivas
Oracle Receivables ivasOracle Receivables ivas
Oracle Receivables ivas
 
Oracle R12 iProcurement Reference Guide
Oracle R12 iProcurement Reference GuideOracle R12 iProcurement Reference Guide
Oracle R12 iProcurement Reference Guide
 
Creating xml publisher documents with people code
Creating xml publisher documents with people codeCreating xml publisher documents with people code
Creating xml publisher documents with people code
 
Consignment inventory
Consignment inventoryConsignment inventory
Consignment inventory
 
5 enterprise structures
5   enterprise structures5   enterprise structures
5 enterprise structures
 
Auto lock box
Auto lock boxAuto lock box
Auto lock box
 

Similar to Oracle's Listagg Function - Uses and Duplicate Removal

C# interview
C# interviewC# interview
C# interview
ajeesharakkal
 
Life of a Label (PromCon2016, Berlin)
Life of a Label (PromCon2016, Berlin)Life of a Label (PromCon2016, Berlin)
Life of a Label (PromCon2016, Berlin)
Brian Brazil
 
Java performance
Java performanceJava performance
Java performance
Rajesuwer P. Singaravelu
 
Oracle's ListAgg Function & Pertinent Use
Oracle's ListAgg Function & Pertinent UseOracle's ListAgg Function & Pertinent Use
Oracle's ListAgg Function & Pertinent Use
Bryan L. Mack
 
Java 8
Java 8Java 8
Best practices in enterprise applications
Best practices in enterprise applicationsBest practices in enterprise applications
Best practices in enterprise applicationsChandra Sekhar Saripaka
 
Linq To The Enterprise
Linq To The EnterpriseLinq To The Enterprise
Linq To The EnterpriseDaniel Egan
 
Cs30 New
Cs30 NewCs30 New
Practical catalyst
Practical catalystPractical catalyst
Practical catalyst
dwm042
 
techniques for removing smallest Stopping sets in LDPC codes
techniques for removing smallest Stopping sets in LDPC codestechniques for removing smallest Stopping sets in LDPC codes
techniques for removing smallest Stopping sets in LDPC codes
Shankar Lal
 
C# interview-questions
C# interview-questionsC# interview-questions
C# interview-questions
nicolbiden
 
IJCER (www.ijceronline.com) International Journal of computational Engineerin...
IJCER (www.ijceronline.com) International Journal of computational Engineerin...IJCER (www.ijceronline.com) International Journal of computational Engineerin...
IJCER (www.ijceronline.com) International Journal of computational Engineerin...ijceronline
 
136 latest dot net interview questions
136  latest dot net interview questions136  latest dot net interview questions
136 latest dot net interview questionssandi4204
 
Code Metrics
Code MetricsCode Metrics
Code Metrics
Attila Bertók
 
Ingesting Over Four Million Rows Per Second With QuestDB Timeseries Database ...
Ingesting Over Four Million Rows Per Second With QuestDB Timeseries Database ...Ingesting Over Four Million Rows Per Second With QuestDB Timeseries Database ...
Ingesting Over Four Million Rows Per Second With QuestDB Timeseries Database ...
javier ramirez
 
C# interview questions
C# interview questionsC# interview questions
C# interview questions
Chetan Chaudhari
 
Jcl faqs
Jcl faqsJcl faqs
Jcl faqs
kapa rohit
 
Learn To Code: Diving deep into java
Learn To Code: Diving deep into javaLearn To Code: Diving deep into java
Learn To Code: Diving deep into java
SadhanaParameswaran
 
SF1 - Apex Development Best Practises
SF1 - Apex Development Best PractisesSF1 - Apex Development Best Practises
SF1 - Apex Development Best Practises
Sebastian Wagner
 
Linq 1224887336792847 9
Linq 1224887336792847 9Linq 1224887336792847 9
Linq 1224887336792847 9google
 

Similar to Oracle's Listagg Function - Uses and Duplicate Removal (20)

C# interview
C# interviewC# interview
C# interview
 
Life of a Label (PromCon2016, Berlin)
Life of a Label (PromCon2016, Berlin)Life of a Label (PromCon2016, Berlin)
Life of a Label (PromCon2016, Berlin)
 
Java performance
Java performanceJava performance
Java performance
 
Oracle's ListAgg Function & Pertinent Use
Oracle's ListAgg Function & Pertinent UseOracle's ListAgg Function & Pertinent Use
Oracle's ListAgg Function & Pertinent Use
 
Java 8
Java 8Java 8
Java 8
 
Best practices in enterprise applications
Best practices in enterprise applicationsBest practices in enterprise applications
Best practices in enterprise applications
 
Linq To The Enterprise
Linq To The EnterpriseLinq To The Enterprise
Linq To The Enterprise
 
Cs30 New
Cs30 NewCs30 New
Cs30 New
 
Practical catalyst
Practical catalystPractical catalyst
Practical catalyst
 
techniques for removing smallest Stopping sets in LDPC codes
techniques for removing smallest Stopping sets in LDPC codestechniques for removing smallest Stopping sets in LDPC codes
techniques for removing smallest Stopping sets in LDPC codes
 
C# interview-questions
C# interview-questionsC# interview-questions
C# interview-questions
 
IJCER (www.ijceronline.com) International Journal of computational Engineerin...
IJCER (www.ijceronline.com) International Journal of computational Engineerin...IJCER (www.ijceronline.com) International Journal of computational Engineerin...
IJCER (www.ijceronline.com) International Journal of computational Engineerin...
 
136 latest dot net interview questions
136  latest dot net interview questions136  latest dot net interview questions
136 latest dot net interview questions
 
Code Metrics
Code MetricsCode Metrics
Code Metrics
 
Ingesting Over Four Million Rows Per Second With QuestDB Timeseries Database ...
Ingesting Over Four Million Rows Per Second With QuestDB Timeseries Database ...Ingesting Over Four Million Rows Per Second With QuestDB Timeseries Database ...
Ingesting Over Four Million Rows Per Second With QuestDB Timeseries Database ...
 
C# interview questions
C# interview questionsC# interview questions
C# interview questions
 
Jcl faqs
Jcl faqsJcl faqs
Jcl faqs
 
Learn To Code: Diving deep into java
Learn To Code: Diving deep into javaLearn To Code: Diving deep into java
Learn To Code: Diving deep into java
 
SF1 - Apex Development Best Practises
SF1 - Apex Development Best PractisesSF1 - Apex Development Best Practises
SF1 - Apex Development Best Practises
 
Linq 1224887336792847 9
Linq 1224887336792847 9Linq 1224887336792847 9
Linq 1224887336792847 9
 

More from Bryan L. Mack

Custom Star Creation for Ellucain's Enterprise Data Warehouse
Custom Star Creation for Ellucain's Enterprise Data WarehouseCustom Star Creation for Ellucain's Enterprise Data Warehouse
Custom Star Creation for Ellucain's Enterprise Data Warehouse
Bryan L. Mack
 
Extending the Admin UI: Proactively Preventing Poor BPRA Load/Refresh Perform...
Extending the Admin UI: Proactively Preventing Poor BPRA Load/Refresh Perform...Extending the Admin UI: Proactively Preventing Poor BPRA Load/Refresh Perform...
Extending the Admin UI: Proactively Preventing Poor BPRA Load/Refresh Perform...
Bryan L. Mack
 
Cognos Macros: Situational Examples & Syntax
Cognos Macros: Situational Examples & SyntaxCognos Macros: Situational Examples & Syntax
Cognos Macros: Situational Examples & Syntax
Bryan L. Mack
 
EDW PK Violation Troubleshooting Made Easy
EDW PK Violation Troubleshooting Made EasyEDW PK Violation Troubleshooting Made Easy
EDW PK Violation Troubleshooting Made Easy
Bryan L. Mack
 
SRP Implementation Success in a Complex Environment
SRP Implementation Success in a Complex EnvironmentSRP Implementation Success in a Complex Environment
SRP Implementation Success in a Complex Environment
Bryan L. Mack
 
Cognos Macros
Cognos MacrosCognos Macros
Cognos Macros
Bryan L. Mack
 
ODS Data Sleuth: Tracking Down Calculated Fields in Banner
ODS Data Sleuth: Tracking Down Calculated Fields in BannerODS Data Sleuth: Tracking Down Calculated Fields in Banner
ODS Data Sleuth: Tracking Down Calculated Fields in Banner
Bryan L. Mack
 

More from Bryan L. Mack (7)

Custom Star Creation for Ellucain's Enterprise Data Warehouse
Custom Star Creation for Ellucain's Enterprise Data WarehouseCustom Star Creation for Ellucain's Enterprise Data Warehouse
Custom Star Creation for Ellucain's Enterprise Data Warehouse
 
Extending the Admin UI: Proactively Preventing Poor BPRA Load/Refresh Perform...
Extending the Admin UI: Proactively Preventing Poor BPRA Load/Refresh Perform...Extending the Admin UI: Proactively Preventing Poor BPRA Load/Refresh Perform...
Extending the Admin UI: Proactively Preventing Poor BPRA Load/Refresh Perform...
 
Cognos Macros: Situational Examples & Syntax
Cognos Macros: Situational Examples & SyntaxCognos Macros: Situational Examples & Syntax
Cognos Macros: Situational Examples & Syntax
 
EDW PK Violation Troubleshooting Made Easy
EDW PK Violation Troubleshooting Made EasyEDW PK Violation Troubleshooting Made Easy
EDW PK Violation Troubleshooting Made Easy
 
SRP Implementation Success in a Complex Environment
SRP Implementation Success in a Complex EnvironmentSRP Implementation Success in a Complex Environment
SRP Implementation Success in a Complex Environment
 
Cognos Macros
Cognos MacrosCognos Macros
Cognos Macros
 
ODS Data Sleuth: Tracking Down Calculated Fields in Banner
ODS Data Sleuth: Tracking Down Calculated Fields in BannerODS Data Sleuth: Tracking Down Calculated Fields in Banner
ODS Data Sleuth: Tracking Down Calculated Fields in Banner
 

Recently uploaded

FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
Ana-Maria Mihalceanu
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
Cheryl Hung
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
91mobiles
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
Laura Byrne
 
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
Product School
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Albert Hoitingh
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
Safe Software
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
Jemma Hussein Allen
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
Guy Korland
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
BookNet Canada
 
Knowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and backKnowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and back
Elena Simperl
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
Thijs Feryn
 
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Ramesh Iyer
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
KatiaHIMEUR1
 
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
Product School
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance
 
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Tobias Schneck
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
OnBoard
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance
 

Recently uploaded (20)

FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
 
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
 
Knowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and backKnowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and back
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
 
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
 
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
 
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
 

Oracle's Listagg Function - Uses and Duplicate Removal

  • 1. Yes, I demonstrated this in 2013 at Coder’s Corner, but I’ve learned more Bryan L. Mack 04/15/2016
  • 3. Pivot Options – sys_connect_by_path Cumbersome, but it works with no sequence number. Still – too lengthy for my taste.
  • 4. Pivot Options – max(decode( When you have a sequence number  If no sequence exists, you can create one in-line  You need to know how many entries exist  May need to rtrim the final delimiter or do a REPLACE on extra delimiters
  • 6. Why use ListAgg?  Dynamic (knows how many rows exist in a group, so is superior to using MAX(DECODE(<seq#  Can use any delimiter you’d like  Can concatenate multiple fields  Simplistic code
  • 7. ListAgg Syntax – Required Components Required Components  Column(s) to be aggregated  The WITHIN GROUP keywords  The ORDER BY clause within the grouping GROUP BY must be used for the entire block
  • 9. Example #2 – Repeated Values
  • 10. Example #2 – 2 ways to get rid of duplicates Option #1 – create distinct data set and pull from it:
  • 11. Example #2 – 2 ways to get rid of duplicates  Option #2 – Use Regular Expressions
  • 12. Side note: If using the RegExp method and your delimiter is not “comma space” (‘, ‘) – then replace the three “, “ references on the 4th line of code with your delimiter. Here is an example with a colon and no space:
  • 13. Function to do this for you create or replace function distinct_listagg (listagg_in varchar2, delimiter_in varchar2) return varchar2 as hold_result varchar2(4000); begin select rtrim( regexp_replace( (listagg_in) , '([^'||delimiter_in||']*)('|| delimiter_in||'1)+($|'||delimiter_in||')', '13'), ',') into hold_result from dual; return hold_result; end;
  • 14. Function to do this for you  Example: The listagg function as such:  listagg(ia.mif_value,',') within GROUP (ORDER BY ia.person_uid, ia.academic_period)  Returns: CCA,CCA,CCA,CCD,CCD,CCD,CCD   Example using my function:  distinct_listagg(listagg(ia.mif_value,',') within GROUP (ORDER BY ia.person_uid, ia.academic_period),  ',')  Returns: CCA,CCD