pc2phone=> select sum(fcall_time),count(fpin) from t_prepaid_history where date_trunc(fcall_start_time)=date_trunc(sysdate-1); 
ERROR: Function 'date_trunc(timestamptz)' does not exist 
Unable to identify a function that satisfies the given argument types 
You may need to add explicit typecasts这句话错在哪里?我想取前一天的值.我现在想做这么一件事,在 linux 中写个脚写,定时去执行刚刚写的那句话,然后输出到一个CSV的文件中去

解决方案 »

  1.   

    pc2phone=> COPY (select sum(fcall_time),count(fpin) from t_prepaid_history where date_trunc('day',fcall_start_time)=current_date-1) to '/root/a.csv' with csv;
    ERROR:  parser: parse error at or near "("我想将执行后的结果copy到/root/下的a.csv文件中,但提示()出错,请问哪位朋友知道是什么意思?谢谢!
      

  2.   

    你date_trunc这个函数语法不对吧?
      

  3.   

    各位高手,我单独执行 select sum(fcall_time),count(fpin) from t_prepaid_history where date_trunc('day',fcall_start_time)=current_date-1 这个SQL语句是正常的,可以正常提取我所需要的值.但我想将得出来的值copy到一个文件中时,用copy命令就出错了.结果如下:
    pc2phone=> COPY (select sum(fcall_time),count(fpin) from t_prepaid_history where date_trunc('day',fcall_start_time)=current_date-1) to '/root/a.csv' with csv; 
    ERROR:  parser: parse error at or near "(" 我试着用copy命令执行其它的SQL语句,如:COPY (select * from table) to '/root/a.csv' with csv; 都是正常的,请各位高手指点明确一些,我查了 date_trunc 函数也没发现错在哪里,谢谢各位高手了。
      

  4.   

    可能是copy不支持多重括号
    建立一个视图,然后导出,或者临时表
      

  5.   

    date_trunc(text, timestamp)你的函数调用缺少参数
      

  6.   

    你用的PostgreSQL的版本号是什么?