SlideShare ist ein Scribd-Unternehmen logo
1 von 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

Weitere ähnliche Inhalte

Was ist angesagt?

Evaluating Algebraic Expressions
Evaluating Algebraic ExpressionsEvaluating Algebraic Expressions
Evaluating Algebraic Expressions
bizarregirl
 
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
ReinabelleMarfilMarq
 
Factoring Polynomials
Factoring PolynomialsFactoring Polynomials
Factoring Polynomials
itutor
 
2/27/12 Special Factoring - Sum & Difference of Two Cubes
2/27/12 Special Factoring - Sum & Difference of Two Cubes2/27/12 Special Factoring - Sum & Difference of Two Cubes
2/27/12 Special Factoring - Sum & Difference of Two Cubes
jennoga08
 
Multiplying polynomials
Multiplying polynomialsMultiplying polynomials
Multiplying polynomials
chrystal_brinson
 

Was ist angesagt? (20)

Rational exponents and radicals
Rational exponents and radicals Rational exponents and radicals
Rational exponents and radicals
 
Rational Expressions
Rational ExpressionsRational Expressions
Rational Expressions
 
Evaluating Algebraic Expressions
Evaluating Algebraic ExpressionsEvaluating Algebraic Expressions
Evaluating Algebraic Expressions
 
Lesson 1: Special Products
Lesson 1: Special ProductsLesson 1: Special Products
Lesson 1: Special Products
 
Mathematics 10 - Lesson 1: Number Pattern
Mathematics 10 - Lesson 1: Number PatternMathematics 10 - Lesson 1: Number Pattern
Mathematics 10 - Lesson 1: Number Pattern
 
Adding and Subtracting Polynomials - Math 7 Q2W4 LC1
Adding and Subtracting Polynomials - Math 7 Q2W4 LC1Adding and Subtracting Polynomials - Math 7 Q2W4 LC1
Adding and Subtracting Polynomials - Math 7 Q2W4 LC1
 
Math 8 - Linear Functions
Math 8 - Linear FunctionsMath 8 - Linear Functions
Math 8 - Linear Functions
 
union and intersection of events.ppt
union and intersection of events.pptunion and intersection of events.ppt
union and intersection of events.ppt
 
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
 
Sample space, events, outcomes, and experiments
Sample space, events, outcomes, and experimentsSample space, events, outcomes, and experiments
Sample space, events, outcomes, and experiments
 
Factoring Polynomials
Factoring PolynomialsFactoring Polynomials
Factoring Polynomials
 
2.4 Linear Functions
2.4 Linear Functions2.4 Linear Functions
2.4 Linear Functions
 
Factoring Polynomials
Factoring PolynomialsFactoring Polynomials
Factoring Polynomials
 
Classifying Polynomials
Classifying PolynomialsClassifying Polynomials
Classifying Polynomials
 
Union and Intersection of Sets
Union and Intersection of SetsUnion and Intersection of Sets
Union and Intersection of Sets
 
Addition and subtraction of rational expression
Addition and subtraction of rational expressionAddition and subtraction of rational expression
Addition and subtraction of rational expression
 
Subsets of real numbers
Subsets of real numbersSubsets of real numbers
Subsets of real numbers
 
Polygons
PolygonsPolygons
Polygons
 
2/27/12 Special Factoring - Sum & Difference of Two Cubes
2/27/12 Special Factoring - Sum & Difference of Two Cubes2/27/12 Special Factoring - Sum & Difference of Two Cubes
2/27/12 Special Factoring - Sum & Difference of Two Cubes
 
Multiplying polynomials
Multiplying polynomialsMultiplying polynomials
Multiplying polynomials
 

Andere mochten auch

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
Jason Aubrey
 
12.4 probability of compound events
12.4 probability of compound events12.4 probability of compound events
12.4 probability of compound events
hisema01
 
Probability Powerpoint
Probability PowerpointProbability Powerpoint
Probability Powerpoint
spike2904
 
4.4 probability of compound events
4.4 probability of compound events4.4 probability of compound events
4.4 probability of compound events
hisema01
 
Probability; Compound Event, Permutations
Probability; Compound Event, PermutationsProbability; Compound Event, Permutations
Probability; Compound Event, Permutations
Reversearp
 
Probability - Independent & Dependent Events
Probability - Independent & Dependent EventsProbability - Independent & Dependent Events
Probability - Independent & Dependent Events
Bitsy Griffin
 
Circular Permutation
Circular PermutationCircular Permutation
Circular Permutation
precious_012526
 
10.6 compound events
10.6 compound events10.6 compound events
10.6 compound events
andreagoings
 
Lesson 11 5 compound events
Lesson 11 5 compound eventsLesson 11 5 compound events
Lesson 11 5 compound events
mlabuski
 
Conditional Probability
Conditional ProbabilityConditional Probability
Conditional Probability
shannonrenee4
 
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
Cryptic Mae Lazarte
 
Chinese festivals中国节日(英文介绍)
Chinese festivals中国节日(英文介绍)Chinese festivals中国节日(英文介绍)
Chinese festivals中国节日(英文介绍)
Michelle Fan
 
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
Jayant Namrani
 

Andere mochten auch (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
 

Mehr von baabtra.com - No. 1 supplier of quality freshers

Mehr von 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
 

KĂźrzlich hochgeladen

IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
Enterprise Knowledge
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
Enterprise Knowledge
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
Earley Information Science
 

KĂźrzlich hochgeladen (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
 
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...
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
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
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
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
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
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
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
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...
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
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...
 

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