Answer the question
In order to leave comments, you need to log in
How to get the number of repetitions?
I understand that the basis of the basics is wildly stupid and I ask for your help.
We have a table that contains the following fields:
Call_date contains the Date
AON call time contains the caller's number . It is
necessary to receive an output by the number of calls from clients who called back within a day from the moment of the last call
. The output should receive the format
Date | Number of repeated calls
Answer the question
In order to leave comments, you need to log in
Something like this
SELECT Date, COUNT(*)
FROM (SELECT old.*
FROM MyTable old, MyTable new
WHERE new.AON = old.AON
AND new.Date = DATEADD (DAY , -1, old.Date)
)
GROUP BY Date
I don't know MS Sql syntax, but probably something like this:
select t1.Call_date
t1.AON
count(*) cnt
from tab1 t1
left join tab1 t2 ON t2.AON = t1.AON
where t2.Call_date between t1.Call_date
and t1.Call_date + 1
group by t1.Call_date
t1.AON
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question