Strange CDR query results

Hey folks! I have some weird results I am getting when querying my CDR table from asteriskcdrdb. I am using this query

SELECT 
calldate AS Timestamp,
clid AS Caller,
src AS Source,
dst AS Destination,
SEC_TO_TIME(duration) AS Duration,
uniqueid AS ID_if_needed 
FROM asteriskcdrdb.cdr WHERE src LIKE '66%' AND calldate > 
date_sub(now(),
interval 24 HOUR) GROUP BY ID_if_needed,
ID_if_needed ORDER BY Timestamp DESC,
ID_if_needed DESC

I get some results from this. I would think I should see any extension starting with “66” from that past day with this query.
When I go and look inside ucp at one of my extensions that don’t show up in this query at all for its call history I see lots of calls. So I am confused if are they being stored somewhere else I don’t know about somehow? Or maybe my query is somehow weird but its not too complex a query it seems like.

Have you done a more basic query to test that it works? As in, I got everything that started with 66 and in the last 24 hours? Also, why are you grouping by the same thing twice? GROUP BY ID_if_needed,ID_if_needed

well trying something like this
sudo mysql -e "select * from asteriskcdrdb.cdr where src LIKE '6674' AND calldate > date_sub(now(), interval 10 DAY)"
Does pull something for that extension but for like over a week ago. There is 100’s more calls for that extension in its history. I only get 3 results for this query for that extension so that makes no sense.

How about something really, really, really simple:

WHERE src LIKE '6674%' AND calldate >= '2022-11-15 00:00:00'

Do you get all the calls for today?

So ya that query nets me only one result and there has been several calls incoming and outgoing all day today. I’m stumped :frowning:

This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.