php - select rows from MySQL where col1 is value and another row where col1 is not value based on col2 related values -


i have table in mysql database has columns:

  • callid
  • event

i want select rows event 'enterqueue' doing in below query:

select count(*) voipnow.ast_queue_log queuename = '0536*401'   , date(time) = '2014-03-07'   , event = 'enterqueue' order time desc; 

but want show number of rows event column not equal connect callid equal callid column above query

update:

what happens is, when call comes database row inserted

example:

callid - 1234 event - enterqueue 

then call circles round without being answered data inserted:

callid - 1234 event - ringnoanswer 

then once call answered, data

callid - 1234 event - connect 

and once call hung up

callid - 1234 event - completeagent or completeagent 

if caller hangs before being answered

callid - 1234 event - abandon 

so when caller waiting there ever rows events enterqueue or ringnoanswer

i want show number of rows above, query need this

i'm sure there faster ways of performing query, here one.

baiscally want ringnoanswers not followed connect or abandon. first connect/abandons , ringnoanswers callid not equal connect/abadon-list... want. so:

select count(distinct `callid`) `voipnow`.`ast_queue_log` `event`='ringnoanswer' , `callid` not in (select `callid` `voipnow`.`ast_queue_log` `event`='connect' or `event`='abandon') 

Comments

Popular posts from this blog

php - SPIP: From Tag directly to an article -

jquery - isAjaxRequest always return false -

ruby on rails - In a controller spec, how to find a specific tag in the generated view? -