SlideShare una empresa de Scribd logo
1 de 28
Disclaimer: This presentation is prepared by trainees of
baabtra as a part of mentoring program. This is not official
document of baabtra –Mentoring Partner
Baabtra-Mentoring Partner is the mentoring division of baabte System Technologies Pvt .
Ltd
Union and Intersection




         Zabeeb anwar
         zabeebanwar@gmail.com
         www.fb.com/zabeebanwar
         twitter.com/zabeebanwar
         in/linkedin.com/in/zabeeb
          9895599689
union
                       AUB
- AUB(OR) means the union of sets A and B
  contains all of the elements of both A and B.
Intersection
AÇB(AND) means the intersection of sets A
and B. This contains all of the elements which
are in both A and B.
Union and Intersection with empty
Union and Intersection in Psql
Union
- A hot startup is holding a special event and
  wants to send out invites for my marriage()
  to some of my best clients and also to some
  VIPs.
- Some of the VIPs are actually very supportive
  of the site and are clients too.
- What query will provide the complete set of
  people to invite avoiding duplicate records?
- Here is our data.
Union
• create database hotstartup;
• create table clients(name varchar);
  insert into clients values(‘Sharan');
  insert into clients values(‘Vineesh');
  insert into clients values(‘Bala');
  insert into clients values(‘Sheethal');
• create table vips(name varchar);
  insert into vips values(‘Reshmi');
  insert into vips values(‘Sheethal');
  insert into vips values(‘Anupa');
  insert into vips values(‘Ashwathy');
Union
• hotstartup=# select * from clients union select *
  from vips;
   name
  ----------------
   Sharan
   Vineesh
   Bala
   Sheethal
   Reshmi
   Anupa
   Ashwathy
  (7 rows)
Union All
• hotstartup=# select * from clients union all select * from vips;
       name
   ----------------
   Sharan
   Vineesh
   Bala
   Sheethal
   Reshmi
   sheethal
   Anupa
   Ashwathy
  (8 rows)
Intersect
• if I want to get the list of people who are both
  clients and VIP we can use INTERSECT.
• hotstartup=# select * from
  clients intersect select * from vips;
       name
  ----------------
   Sheethal
   (1 row)
Intersect All
•    Let's insert a Sheethal(duplicate name) into VIP’s.
      name
    ----------------
    Sharan
    Vineesh
    Bala
    Sheethal
     Sheethal
    (4 rows)

-select * from client intersect all select * from vips;
Intersect All
  name
 ----------------
  sheethal
  sheethal

   (2 rows)
- Sheethal appears in both tables twice so we
  find two matching pairs for her and hence two
  rows appears in the results.
Except
• I want everyone on the clients list EXCEPT those on
  the VIP list.
• select * from clients except select * from vips;
  name
  ----------------
  Sharan
  Vineesh
  Bala
Except All
• Let's insert a Sheethal(duplicate name) into clients.
    name
   ----------------
   Sharan
   Vineesh
   Bala
   Sheethal
  Sheethal
    (4 rows)
-select * from clients except all select * from vips;
Except All
 name
----------------
Sharan
Vineesh
Bala
Sheethal
 (4 rows)
Where Clause
• select * from Clients_Year;
       name         | Birth year
  ------------------+------
   Sharan        | 1976
   Vineesh | 1977
   Bala       | 1978
   Ashwathy | 1983
   Reshmi | 199 3
   sheethal | 1996
   Anupa        | 1997
Where Clause
• select * from clients_year where year
  between 1970 and 1979 union select * from
  ceos where year=1977;
    name        | Birth year
  ------------------+------
   Sharan | 1976
   Vineesh | 1977
   Bala         | 1978
Do not
• select * from clients where year between
  1970 and 1979 union select name from clients
  where year=1977;
  ERROR: each UNION query must have the
  same number of columns
Union and intersection in Python
Example
>>>engineers = Set(['John', 'Jane', 'Jack',
  'Janice'])

>>>programmers = Set(['Jack', 'Sam', 'Susan',
  'Janice'])

>>>managers = Set(['Jane', 'Jack', 'Susan',
  'Zack'])
Union
>>>employees = engineers | programmers |
  managers
>>>print “employees”
Set(['Jane', 'Janice', 'John’,
  'Jack’,’susan’,’Zack’,’sam’])
Intersection
>>>engineers = Set(['John', 'Jane', 'Jack',
  'Janice'])
>>>managers = Set(['Jane', 'Jack', 'Susan',
  'Zack'])
>>>engineering_management = engineers &
  managers
>>>print “engineering_management”
Set(['Jane', 'Jack’])
Questions
If this presentation helped you, please visit our
           page facebook.com/baabtra and like it.
                 Thanks in advance.
www.baabtra.com | www.massbaab.com |www.baabte.com
Contact Us

Más contenido relacionado

La actualidad más candente

Harmonic and Other Sequences
Harmonic and Other SequencesHarmonic and Other Sequences
Harmonic and Other Sequencesstephendy999
 
Cartesian Coordinate Plane - Mathematics 8
Cartesian Coordinate Plane - Mathematics 8Cartesian Coordinate Plane - Mathematics 8
Cartesian Coordinate Plane - Mathematics 8Carlo Luna
 
Union & Intersection of Sets
Union & Intersection of SetsUnion & Intersection of Sets
Union & Intersection of Setsmyla gambalan
 
Organizing data using frequency distribution
Organizing data using frequency distributionOrganizing data using frequency distribution
Organizing data using frequency distributionKennyAnnGraceBatianc
 
Probability of Union of Two events
Probability of Union of Two eventsProbability of Union of Two events
Probability of Union of Two eventsJAYHARYLPESALBON1
 
PROBABILITY OF MUTUALLY EXCLUSIVE EVENTS final.pptx
PROBABILITY OF MUTUALLY EXCLUSIVE EVENTS final.pptxPROBABILITY OF MUTUALLY EXCLUSIVE EVENTS final.pptx
PROBABILITY OF MUTUALLY EXCLUSIVE EVENTS final.pptxReinabelleMarfilMarq
 
COT2 Lesson Plan Grade 8
COT2  Lesson Plan Grade 8COT2  Lesson Plan Grade 8
COT2 Lesson Plan Grade 8RoselynOntolan
 
Simplification of Fractions and Operations on Fractions
Simplification of Fractions and Operations on FractionsSimplification of Fractions and Operations on Fractions
Simplification of Fractions and Operations on FractionsVer Louie Gautani
 
Subsets of real numbers
Subsets of real numbersSubsets of real numbers
Subsets of real numbersGrace Robledo
 
permutations power point
permutations power pointpermutations power point
permutations power pointAldrin Balenton
 
Lesson plan math 10 2 nd grading
Lesson plan math 10 2 nd gradingLesson plan math 10 2 nd grading
Lesson plan math 10 2 nd gradingNnelgebar
 
Lesson plan on Linear inequalities in two variables
Lesson plan on Linear inequalities in two variablesLesson plan on Linear inequalities in two variables
Lesson plan on Linear inequalities in two variablesLorie Jane Letada
 
Rectangular coordinate system
Rectangular coordinate systemRectangular coordinate system
Rectangular coordinate systemCathy Francisco
 
Operations with Radicals
Operations with RadicalsOperations with Radicals
Operations with Radicalscmorgancavo
 

La actualidad más candente (20)

Harmonic and Other Sequences
Harmonic and Other SequencesHarmonic and Other Sequences
Harmonic and Other Sequences
 
Cartesian Coordinate Plane - Mathematics 8
Cartesian Coordinate Plane - Mathematics 8Cartesian Coordinate Plane - Mathematics 8
Cartesian Coordinate Plane - Mathematics 8
 
Union & Intersection of Sets
Union & Intersection of SetsUnion & Intersection of Sets
Union & Intersection of Sets
 
Organizing data using frequency distribution
Organizing data using frequency distributionOrganizing data using frequency distribution
Organizing data using frequency distribution
 
Probability of Union of Two events
Probability of Union of Two eventsProbability of Union of Two events
Probability of Union of Two events
 
Solving Problems Using Venn Diagram
Solving Problems Using Venn DiagramSolving Problems Using Venn Diagram
Solving Problems Using Venn Diagram
 
PROBABILITY OF MUTUALLY EXCLUSIVE EVENTS final.pptx
PROBABILITY OF MUTUALLY EXCLUSIVE EVENTS final.pptxPROBABILITY OF MUTUALLY EXCLUSIVE EVENTS final.pptx
PROBABILITY OF MUTUALLY EXCLUSIVE EVENTS final.pptx
 
Laws Of Exponents
Laws Of ExponentsLaws Of Exponents
Laws Of Exponents
 
COT2 Lesson Plan Grade 8
COT2  Lesson Plan Grade 8COT2  Lesson Plan Grade 8
COT2 Lesson Plan Grade 8
 
Triangle inequalities
Triangle inequalitiesTriangle inequalities
Triangle inequalities
 
Permutations
PermutationsPermutations
Permutations
 
Simplification of Fractions and Operations on Fractions
Simplification of Fractions and Operations on FractionsSimplification of Fractions and Operations on Fractions
Simplification of Fractions and Operations on Fractions
 
Subsets of real numbers
Subsets of real numbersSubsets of real numbers
Subsets of real numbers
 
permutations power point
permutations power pointpermutations power point
permutations power point
 
Lesson plan math 10 2 nd grading
Lesson plan math 10 2 nd gradingLesson plan math 10 2 nd grading
Lesson plan math 10 2 nd grading
 
Lesson plan on Linear inequalities in two variables
Lesson plan on Linear inequalities in two variablesLesson plan on Linear inequalities in two variables
Lesson plan on Linear inequalities in two variables
 
Math-Quiz-Bee.ppt
Math-Quiz-Bee.pptMath-Quiz-Bee.ppt
Math-Quiz-Bee.ppt
 
Rectangular coordinate system
Rectangular coordinate systemRectangular coordinate system
Rectangular coordinate system
 
Remainder theorem
Remainder theoremRemainder theorem
Remainder theorem
 
Operations with Radicals
Operations with RadicalsOperations with Radicals
Operations with Radicals
 

Destacado

Math 1300: Section 8 -2 Union, Intersection, and Complement of Events; Odds
Math 1300: Section 8 -2 Union, Intersection, and Complement of Events; OddsMath 1300: Section 8 -2 Union, Intersection, and Complement of Events; Odds
Math 1300: Section 8 -2 Union, Intersection, and Complement of Events; OddsJason Aubrey
 
12.4 probability of compound events
12.4 probability of compound events12.4 probability of compound events
12.4 probability of compound eventshisema01
 
Probability Powerpoint
Probability PowerpointProbability Powerpoint
Probability Powerpointspike2904
 
PROBABILITY
PROBABILITYPROBABILITY
PROBABILITYVIV13
 
4.4 probability of compound events
4.4 probability of compound events4.4 probability of compound events
4.4 probability of compound eventshisema01
 
Probability; Compound Event, Permutations
Probability; Compound Event, PermutationsProbability; Compound Event, Permutations
Probability; Compound Event, PermutationsReversearp
 
Probability - Independent & Dependent Events
Probability - Independent & Dependent EventsProbability - Independent & Dependent Events
Probability - Independent & Dependent EventsBitsy Griffin
 
10.6 compound events
10.6 compound events10.6 compound events
10.6 compound eventsandreagoings
 
Lesson 11 5 compound events
Lesson 11 5 compound eventsLesson 11 5 compound events
Lesson 11 5 compound eventsmlabuski
 
Conditional Probability
Conditional ProbabilityConditional Probability
Conditional Probabilityshannonrenee4
 
Space craft,space probe,space station,space shuttle and rocket
Space craft,space probe,space station,space shuttle and rocketSpace craft,space probe,space station,space shuttle and rocket
Space craft,space probe,space station,space shuttle and rocketCryptic Mae Lazarte
 
Chinese festivals中国节日(英文介绍)
Chinese festivals中国节日(英文介绍)Chinese festivals中国节日(英文介绍)
Chinese festivals中国节日(英文介绍)Michelle Fan
 
Permutation & Combination
Permutation & CombinationPermutation & Combination
Permutation & CombinationPuru Agrawal
 
Real life situation's example on PROBABILITY
Real life situation's example on PROBABILITYReal life situation's example on PROBABILITY
Real life situation's example on PROBABILITYJayant Namrani
 

Destacado (20)

Math 1300: Section 8 -2 Union, Intersection, and Complement of Events; Odds
Math 1300: Section 8 -2 Union, Intersection, and Complement of Events; OddsMath 1300: Section 8 -2 Union, Intersection, and Complement of Events; Odds
Math 1300: Section 8 -2 Union, Intersection, and Complement of Events; Odds
 
intersection and union
intersection and unionintersection and union
intersection and union
 
12.4 probability of compound events
12.4 probability of compound events12.4 probability of compound events
12.4 probability of compound events
 
Probability Powerpoint
Probability PowerpointProbability Powerpoint
Probability Powerpoint
 
PROBABILITY
PROBABILITYPROBABILITY
PROBABILITY
 
4.4 probability of compound events
4.4 probability of compound events4.4 probability of compound events
4.4 probability of compound events
 
Probability; Compound Event, Permutations
Probability; Compound Event, PermutationsProbability; Compound Event, Permutations
Probability; Compound Event, Permutations
 
Probability - Independent & Dependent Events
Probability - Independent & Dependent EventsProbability - Independent & Dependent Events
Probability - Independent & Dependent Events
 
Circular Permutation
Circular PermutationCircular Permutation
Circular Permutation
 
Sets in mathematics
Sets in mathematicsSets in mathematics
Sets in mathematics
 
10.6 compound events
10.6 compound events10.6 compound events
10.6 compound events
 
Lesson 11 5 compound events
Lesson 11 5 compound eventsLesson 11 5 compound events
Lesson 11 5 compound events
 
Conditional Probability
Conditional ProbabilityConditional Probability
Conditional Probability
 
Space craft,space probe,space station,space shuttle and rocket
Space craft,space probe,space station,space shuttle and rocketSpace craft,space probe,space station,space shuttle and rocket
Space craft,space probe,space station,space shuttle and rocket
 
Chinese festivals中国节日(英文介绍)
Chinese festivals中国节日(英文介绍)Chinese festivals中国节日(英文介绍)
Chinese festivals中国节日(英文介绍)
 
Permutation & Combination
Permutation & CombinationPermutation & Combination
Permutation & Combination
 
Social dance
Social danceSocial dance
Social dance
 
Ballroom dance
Ballroom danceBallroom dance
Ballroom dance
 
Real life situation's example on PROBABILITY
Real life situation's example on PROBABILITYReal life situation's example on PROBABILITY
Real life situation's example on PROBABILITY
 
Set concepts
Set conceptsSet concepts
Set concepts
 

Más de baabtra.com - No. 1 supplier of quality freshers

Más de baabtra.com - No. 1 supplier of quality freshers (20)

Agile methodology and scrum development
Agile methodology and scrum developmentAgile methodology and scrum development
Agile methodology and scrum development
 
Best coding practices
Best coding practicesBest coding practices
Best coding practices
 
Core java - baabtra
Core java - baabtraCore java - baabtra
Core java - baabtra
 
Acquiring new skills what you should know
Acquiring new skills   what you should knowAcquiring new skills   what you should know
Acquiring new skills what you should know
 
Baabtra.com programming at school
Baabtra.com programming at schoolBaabtra.com programming at school
Baabtra.com programming at school
 
99LMS for Enterprises - LMS that you will love
99LMS for Enterprises - LMS that you will love 99LMS for Enterprises - LMS that you will love
99LMS for Enterprises - LMS that you will love
 
Php sessions & cookies
Php sessions & cookiesPhp sessions & cookies
Php sessions & cookies
 
Php database connectivity
Php database connectivityPhp database connectivity
Php database connectivity
 
Chapter 6 database normalisation
Chapter 6  database normalisationChapter 6  database normalisation
Chapter 6 database normalisation
 
Chapter 5 transactions and dcl statements
Chapter 5  transactions and dcl statementsChapter 5  transactions and dcl statements
Chapter 5 transactions and dcl statements
 
Chapter 4 functions, views, indexing
Chapter 4  functions, views, indexingChapter 4  functions, views, indexing
Chapter 4 functions, views, indexing
 
Chapter 3 stored procedures
Chapter 3 stored proceduresChapter 3 stored procedures
Chapter 3 stored procedures
 
Chapter 2 grouping,scalar and aggergate functions,joins inner join,outer join
Chapter 2  grouping,scalar and aggergate functions,joins   inner join,outer joinChapter 2  grouping,scalar and aggergate functions,joins   inner join,outer join
Chapter 2 grouping,scalar and aggergate functions,joins inner join,outer join
 
Chapter 1 introduction to sql server
Chapter 1 introduction to sql serverChapter 1 introduction to sql server
Chapter 1 introduction to sql server
 
Chapter 1 introduction to sql server
Chapter 1 introduction to sql serverChapter 1 introduction to sql server
Chapter 1 introduction to sql server
 
Microsoft holo lens
Microsoft holo lensMicrosoft holo lens
Microsoft holo lens
 
Blue brain
Blue brainBlue brain
Blue brain
 
5g
5g5g
5g
 
Aptitude skills baabtra
Aptitude skills baabtraAptitude skills baabtra
Aptitude skills baabtra
 
Gd baabtra
Gd baabtraGd baabtra
Gd baabtra
 

Último

GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesBoston Institute of Analytics
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilV3cube
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...apidays
 
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
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
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
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdflior mazor
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobeapidays
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
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
 

Último (20)

GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
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
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
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
 

Union and intersection

  • 1.
  • 2. Disclaimer: This presentation is prepared by trainees of baabtra as a part of mentoring program. This is not official document of baabtra –Mentoring Partner Baabtra-Mentoring Partner is the mentoring division of baabte System Technologies Pvt . Ltd
  • 3. Union and Intersection Zabeeb anwar zabeebanwar@gmail.com www.fb.com/zabeebanwar twitter.com/zabeebanwar in/linkedin.com/in/zabeeb 9895599689
  • 4. union AUB - AUB(OR) means the union of sets A and B contains all of the elements of both A and B.
  • 5. Intersection AÇB(AND) means the intersection of sets A and B. This contains all of the elements which are in both A and B.
  • 8. Union - A hot startup is holding a special event and wants to send out invites for my marriage() to some of my best clients and also to some VIPs. - Some of the VIPs are actually very supportive of the site and are clients too. - What query will provide the complete set of people to invite avoiding duplicate records? - Here is our data.
  • 9. Union • create database hotstartup; • create table clients(name varchar); insert into clients values(‘Sharan'); insert into clients values(‘Vineesh'); insert into clients values(‘Bala'); insert into clients values(‘Sheethal'); • create table vips(name varchar); insert into vips values(‘Reshmi'); insert into vips values(‘Sheethal'); insert into vips values(‘Anupa'); insert into vips values(‘Ashwathy');
  • 10. Union • hotstartup=# select * from clients union select * from vips; name ---------------- Sharan Vineesh Bala Sheethal Reshmi Anupa Ashwathy (7 rows)
  • 11. Union All • hotstartup=# select * from clients union all select * from vips; name ---------------- Sharan Vineesh Bala Sheethal Reshmi sheethal Anupa Ashwathy (8 rows)
  • 12. Intersect • if I want to get the list of people who are both clients and VIP we can use INTERSECT. • hotstartup=# select * from clients intersect select * from vips; name ---------------- Sheethal (1 row)
  • 13. Intersect All • Let's insert a Sheethal(duplicate name) into VIP’s. name ---------------- Sharan Vineesh Bala Sheethal Sheethal (4 rows) -select * from client intersect all select * from vips;
  • 14. Intersect All name ---------------- sheethal sheethal (2 rows) - Sheethal appears in both tables twice so we find two matching pairs for her and hence two rows appears in the results.
  • 15. Except • I want everyone on the clients list EXCEPT those on the VIP list. • select * from clients except select * from vips; name ---------------- Sharan Vineesh Bala
  • 16. Except All • Let's insert a Sheethal(duplicate name) into clients. name ---------------- Sharan Vineesh Bala Sheethal Sheethal (4 rows) -select * from clients except all select * from vips;
  • 18. Where Clause • select * from Clients_Year; name | Birth year ------------------+------ Sharan | 1976 Vineesh | 1977 Bala | 1978 Ashwathy | 1983 Reshmi | 199 3 sheethal | 1996 Anupa | 1997
  • 19. Where Clause • select * from clients_year where year between 1970 and 1979 union select * from ceos where year=1977; name | Birth year ------------------+------ Sharan | 1976 Vineesh | 1977 Bala | 1978
  • 20. Do not • select * from clients where year between 1970 and 1979 union select name from clients where year=1977; ERROR: each UNION query must have the same number of columns
  • 22. Example >>>engineers = Set(['John', 'Jane', 'Jack', 'Janice']) >>>programmers = Set(['Jack', 'Sam', 'Susan', 'Janice']) >>>managers = Set(['Jane', 'Jack', 'Susan', 'Zack'])
  • 23. Union >>>employees = engineers | programmers | managers >>>print “employees” Set(['Jane', 'Janice', 'John’, 'Jack’,’susan’,’Zack’,’sam’])
  • 24. Intersection >>>engineers = Set(['John', 'Jane', 'Jack', 'Janice']) >>>managers = Set(['Jane', 'Jack', 'Susan', 'Zack']) >>>engineering_management = engineers & managers >>>print “engineering_management” Set(['Jane', 'Jack’])
  • 26.
  • 27. If this presentation helped you, please visit our page facebook.com/baabtra and like it. Thanks in advance. www.baabtra.com | www.massbaab.com |www.baabte.com