SQL:错误
ERROR:  function decode(integer, integer, integer, integer) does not exist at character 30
HINT:  No function matches the given name and argument types. You might need to add explicit type casts.
In statement:
请高手指点这句错在哪里?谢谢.
select (trunc(fcall_time/60)+decode(mod(fcall_time,60),0,0,1)) from  t_prepaid_history where to_char(fcall_start_time,'YYYYMM')='200809' group by fdest_phone_country_code;

解决方案 »

  1.   

    decode函数调用错误,要么是名称错误,要么是类型使用错误
      

  2.   

    CREATE OR REPLACE FUNCTION decode(text, text)
      RETURNS bytea AS
    'binary_decode'
      LANGUAGE 'internal' IMMUTABLE STRICT
      COST 1;
    ALTER FUNCTION decode(text, text) OWNER TO postgres;
    COMMENT ON FUNCTION decode(text, text) IS 'convert ascii-encoded text string into bytea value';postgre只有这一个decode的定义,没有你调用的形式
      

  3.   

    请问有什么其它的写法,如果不用decode的话,能达到要求就行.关键是我想把取的模进1
      

  4.   

    decode在楼主的语句里边的作用是什么,不太明白!decode(string text, type text)   返回类型:bytea  
    功能描述:把早先用encode编码的,存放在 string 里面的二进制数据解码。 参数类型和encode一样。 
    例子:decode('MTIzAAE=', 'base64')
      

  5.   

    谢谢你了,涛兄,我也搞不明白到底怎么写了,所以只能偷工减料这么写了,呵呵select (trunc(fcall_time/60)+1) from  t_prepaid_history where to_char(fcall_start_time,'YYYYMM')='200809' group by fdest_phone_country_code;
      

  6.   

    谢谢8楼 mschen 的回复,我主要的意思是想把除下来的小数进1,前面的 trunc 除以 60 会得出一个数字,再加上 mod 取的小数, 把小数当作 1 加到前面的整数里.
      

  7.   

    CREATE OR REPLACE FUNCTION floor(double precision)
      RETURNS double precision AS
    'dfloor'
      LANGUAGE 'internal' IMMUTABLE STRICT
      COST 1;
    ALTER FUNCTION floor(double precision) OWNER TO postgres;
    COMMENT ON FUNCTION floor(double precision) IS 'largest integer <= value';我还没有找到天花板函数。
    这个叫地板函数,针对你这样需求的
    /60.0后取天花板就是你要的了
      

  8.   


    CREATE OR REPLACE FUNCTION ceiling(double precision)
      RETURNS double precision AS
    'dceil'
      LANGUAGE 'internal' IMMUTABLE STRICT
      COST 1;
    ALTER FUNCTION ceiling(double precision) OWNER TO postgres;
    COMMENT ON FUNCTION ceiling(double precision) IS 'smallest integer >= value';
      

  9.   

    秒数是整数?那整除就行了吧?select (consume_time/60)+1
      

  10.   

    或者:
    select cast((consume_time/60)+1 as integer) from a