Results 1 to 3 of 3
  1. #1
    Join Date
    Oct 2012
    Posts
    4

    Unanswered: Help Me. I am a nnewbie

    my two tables like this..


    INCOMING TABLE

    DATE INCOMING _CALLS INCOMING_MINUTES
    1/1/2012 5 120
    3/1/2012 7 159


    OUTGOING TABLE

    DATE OUTGOING _CALLS OUTGOING_MINUTES
    1/1/2012 6 121
    2/1/2012 9 191



    and I want the output like

    OUTPUT TABLE

    DATE INCOMING _CALLS INCOMING_MINUTES OUTGOING _CALLS OUTGOING_MINUTES
    1/1/12 5 120 6 121
    2/1/12 --- --- 9 191
    3/1/12 7 159 -- ---

    where --- means no value.

  2. #2
    Join Date
    Sep 2009
    Location
    San Sebastian, Spain
    Posts
    880
    Try

    SELECT in.Date, in.incoming_calls, in.incoming_minutes, out.outgoing_calls, out.outgoing_minutes
    FROM incoming_table as in
    LEFT JOIN outgoing_table as out ON (in.date = out.date)
    UNION
    SELECT out.Date, in.incoming_calls, in.incoming_minutes, out.outgoing_calls, out.outgoing_minutes
    FROM outgoing_table as out
    LEFT JOIN incoming_table as in ON (out.date = in.date);
    Ronan Cashell
    Certified Oracle DBA/Certified MySQL Expert (DBA & Cluster DBA)
    http://www.it-iss.com
    Follow me on Twitter

  3. #3
    Join Date
    Oct 2012
    Posts
    4
    It works . Thank you Mr.Ronan Cashell.
    I got the logic..

Posting Permissions

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