Change reports calls

Discussion in 'General' started by alfil2k, Dec 3, 2009.

  1. alfil2k

    Joined:
    Aug 17, 2009
    Messages:
    25
    Likes Received:
    0
    Hi all,

    We have a client that need to take out from the report call the internal calls. I can see on the php code this:

    SELECT
    t_devices.id source,
    t_devices.description name,
    ifnull(t_cdr.num_outgoing_call,0) num_outgoing_call,
    ifnull(t_cdr.duration_outgoing_call,0) duration_outgoing_call
    FROM
    (SELECT
    c.src source,
    count(c.src) num_outgoing_call,
    sum(c.billsec) duration_outgoing_call
    FROM
    asteriskcdrdb.cdr c
    WHERE
    c.calldate>='$date_ini' AND
    c.calldate<='$date_end' AND
    c.src like '$extension%'
    GROUP BY c.src) t_cdr
    RIGHT JOIN
    (SELECT
    d.id,
    d.description
    FROM
    asterisk.devices d
    WHERE
    d.id like '$extension%' AND
    d.description like '$description%') t_devices
    ON t_devices.id=t_cdr.source
    LIMIT $limit OFFSET $offset";

    Somebody knows how to change this code to eliminate from the sum and count the internal calls?

    Thanks,
    Pablo
     
  2. alfil2k

    Joined:
    Aug 17, 2009
    Messages:
    25
    Likes Received:
    0
    Ok, nobody knows how to do that? I resolve my resolve issue. The code for make the search whitout internals calls is this:

    (SELECT
    c.src source,
    count(c.src) num_outgoing_call,
    sum(c.billsec) duration_outgoing_call
    FROM
    asteriskcdrdb.cdr c
    WHERE
    c.calldate>='$date_ini' AND
    c.calldate<='$date_end' AND
    c.dst > '7' AND <--- I only added this line :)
    c.src like '$extension%'
    GROUP BY c.src) t_cdr
    RIGHT JOIN
    (SELECT
    d.id,
    d.description
    FROM
    asterisk.devices d
    WHERE
    d.id like '$extension%' AND
    d.description like '$description%') t_devices
    ON t_devices.id=t_cdr.source
    LIMIT $limit OFFSET $offset";

    Regards,
    Pablo
     

Share This Page