Я не могу получить результаты допроса. (postgresql и php) - PullRequest
0 голосов
/ 01 мая 2020

Я хочу искать по выводу, но я делаю что-то не так, как-то не получается. Я использую PostgreSQL.

SELECT 
      CDR.xml_cdr_uuid,
        CDR.direction,
        CDR.caller_id_number,
        CDR.destination_number,
        CDR.start_stamp,
        CDR.end_stamp,
        CDR.duration,
        CDR.record_path,
        CDR.record_name,
CASE  
           WHEN (bridge_uuid is not null) and (answer_stamp is not null) and billsec >0  THEN 'answer'
             WHEN (missed_call = true and bridge_uuid is null) AND (json->'variables'->>'sip_invite_failure_status' IN('487','486','480') ) THEN 'not_call'
             WHEN (answer_stamp is not NULL) and (bridge_uuid is NULL) AND (sip_hangup_disposition !='send_refuse') THEN 'voicemail'
             ELSE 'ROTA_error' END
        as status
FROM v_xml_cdr as CDR
GROUP BY  xml_cdr_uuid
HAVING    ('status' = 'not_call')

enter image description here

1 Ответ

1 голос
/ 01 мая 2020

Попробуйте:

SELECT 
      CDR.xml_cdr_uuid,
        CDR.direction,
        CDR.caller_id_number,
        CDR.destination_number,
        CDR.start_stamp,
        CDR.end_stamp,
        CDR.duration,
        CDR.record_path,
        CDR.record_name,
CASE  
           WHEN (bridge_uuid is not null) and (answer_stamp is not null) and billsec >0  THEN 'answer'
             WHEN (missed_call = true and bridge_uuid is null) AND (json->'variables'->>'sip_invite_failure_status' IN('487','486','480') ) THEN 'not_call'
             WHEN (answer_stamp is not NULL) and (bridge_uuid is NULL) AND (sip_hangup_disposition !='send_refuse') THEN 'voicemail'
             ELSE 'ROTA_error' END
        as status
FROM v_xml_cdr as CDR
GROUP BY  xml_cdr_uuid
HAVING    (CASE  
           WHEN (bridge_uuid is not null) and (answer_stamp is not null) and billsec >0  THEN 'answer'
             WHEN (missed_call = true and bridge_uuid is null) AND (json->'variables'->>'sip_invite_failure_status' IN('487','486','480') ) THEN 'not_call'
             WHEN (answer_stamp is not NULL) and (bridge_uuid is NULL) AND (sip_hangup_disposition !='send_refuse') THEN 'voicemail'
             ELSE 'ROTA_error' END = 'not_call')

Вы пытаетесь сравнить две строки: строку 'status' и строку 'not call' в предложении HAVING. Таким образом, каждый раз это сравнение будет false

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...