Results 1 to 3 of 3

Thread: Putting these results toghether

  1. #1
    Join Date
    Nov 2002
    Posts
    2

    Unhappy Putting these results toghether

    The two queries:

    set dateformat 'dmy'
    select count(c.id), e.name
    from call c left outer join employee e
    on c.req_id = e.id
    where c.posted between '01/01/2002' and '30/11/2002'
    group by e.name
    order by count(c.id) desc

    set dateformat 'dmy'
    select count(ch.id), e.name
    from call_hist ch left outer join employee e
    on ch.req_id = e.id
    where ch.posted between '01/01/2002' and '30/11/2002'
    group by e.name
    order by count(ch.id) desc

    the results:

    42 NULL
    34 Dirk Deloof
    13 Annick Leirman
    11 Ronny Loosen
    9 Geert Benoot
    9 Nicole Ferrari
    8 FLOCK
    8 Mosselmans Christoph
    7 Geert Pets
    7 Mireille Dutrieue
    6 johan
    6 Laurent De Schrijver
    5 Jeanette De SChrijve
    5 Marc De Vlieger
    5 minerva
    5 Pascal Saesen
    5 Rik Haghebaert
    5 Sonja Van Kerckhove
    4 Bcatron
    4 Luc Willems
    3 Brigit Brocken
    3 euroadmin
    3 Francine Kopp
    3 Luc Steyaert
    3 Marie-Rose Buysse
    3 Marnix Van Steirtege
    3 Mattias Denys
    3 Pieter Frooninckx
    3 Reserve
    3 Rik De Scheemaecker
    3 Thierry Linard
    2 Carlos Van Alboom
    2 Dorine Sierens
    2 Els Poelman
    2 Jean Claude Vermeir
    2 Katrien Colman
    2 Kim Impens
    2 Kris Lejeune
    2 MEDreserve01
    2 Roger De Wilde
    1 Agnes Lebon
    1 Carla Van Den Broeck
    1 Eric Vlaeminck

    and

    118 NULL
    58 Marie-Rose Buysse
    47 Dirk Deloof
    45 Ronny Loosen
    43 Annick Leirman
    41 Geert Pets
    38 FLOCK
    38 Pascal Saesen
    28 Teamleiders afwerkin
    24 Kim Impens
    22 Ilse Soetens
    22 Rik Haghebaert
    22 Severine Balduck
    21 Teamleiders print
    20 Mosselmans Christoph
    20 Jeanette De SChrijve
    19 Geert Benoot
    19 Francine Kopp
    18 Geert Meuleman
    17 Rik De Scheemaecker
    16 johan
    16 Katrien Colman
    15 Gaby Eloot
    14 Kris Lejeune
    14 Gilbert Callebaut
    14 Laurent De Schrijver
    13 Els Poelman
    13 Luc Steyaert
    11 Marnix Van Steirtege
    10 Frans Hoogewijs
    10 Sonja Van Kerckhove
    10 Dorine Sierens
    9 Eric Vlaeminck
    9 Thierry Linard
    7 Frederic Denis
    7 Michel Poppe
    6 Carla Van Den Broeck
    6 Pieter Frooninckx
    5 Katlijn Poleyn
    5 MEDreserve01
    5 Mireille Dutrieue
    5 Agnes Lebon
    4 Guido Antoin
    4 Onderhoud
    4 minerva
    4 Jeanette Van Brussel
    3 Roger De Wilde
    3 Sofie Gabriels
    3 Verf2
    3 euroadmin
    3 Marc De Vlieger
    2 Luc Willems
    2 MEDRESERVE07
    2 Regina Decoster
    2 Monique Kohl
    2 MEDRESERVE04
    2 Portier
    2 Bcatron
    2 Pierre Hanet
    2 Tgabriels
    2 Isabelle Torrelle
    2 Nicole Ferrari
    1 Robert Zwaak
    1 Carlos Van Alboom
    1 testuser
    1 Brigit Brocken
    1 Reserve
    1 Opleiding
    1 Verf

    How do I put these results in one? I need not two but one Query.
    Please help me. Thanks

  2. #2
    Join Date
    Nov 2002
    Posts
    2
    This is the solution:

    set dateformat 'dmy'
    select count(distinct c.id)+count(distinct ch.id) as atl, e.name
    from employee e right outer join call c
    on c.req_id = e.id
    right outer join call_hist ch
    on ch.req_id = e.id
    where c.posted between '01/01/2002' and '30/11/2002'
    group by e.name
    order by atl desc

  3. #3
    Join Date
    Dec 2002
    Posts
    3

    Red face

    Put the same alias in the coluns of two querys and use an union or union all.
    The differences between union and union all that union make a distinct in data and union all no..

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •