All pastes #15028 Raw Edit

Mine

public sql v1 · immutable
#15028 ·published 2005-06-19 18:05 UTC
rendered paste body
# here is the test table.create table cdr (  call_id         bigint auto_increment primary key,  call_cid        varchar(32),  call_csid       varchar(32),  call_start      timestamp,  call_end        timestamp,  index call_start_i (call_start),  index call_end_i (call_end));# Paste this by hand about 80 times to generate sample data.set @ts:=(now() - interval cast(rand()*1000 as SIGNED) second); insert into cdr VALUES (null, concat('360555', lpad((cast(rand()*1000 as SIGNED)),4,'0')), concat('206555', lpad((cast(rand()*1000 as SIGNED)),4,'0')), @ts, (@ts + interval cast(rand()*1000 as SIGNED) second) );# then query it :)select a.call_start, (select count(call_id) from cdr as b where ( b.call_start <= a.call_start and b.call_end >= a.call_start) ) as 'Simultanious' from cdr as a group by call_start order by Simultanious;