为什么不在postgresql中执行语句查询?

时间:2017-02-17 09:43:11

标签: sql postgresql

我在函数中写下了通过触发执行的查询。

SELECT report_date INTO logdate FROM agent_statistics WHERE agentid =             
    NEW.caller_id_name AND report_date = DATE(NEW.start_stamp);
SELECT COUNT(*) INTO outbound FROM cdr WHERE (caller_id_name = 
    NEW.caller_id_name AND direction = 'outbound' AND 
    DATE(NEW.start_stamp) = logdate);
SELECT COUNT(*) INTO consult FROM cdr WHERE (caller_id_name =
    NEW.caller_id_name AND direction = 'outbound' AND 
    DATE(NEW.start_stamp) = logdate AND billsec > '0');

这里,logdate值给出了正确的日期。但是,outbound和consult提供了表中的所有行。表示前一个日期还包括不包括的日期。 我只需要当前日期总行数。

1 个答案:

答案 0 :(得分:0)

替换您的DATE(NEW.start_stamp) = logdate);start_stamp = logdate);