Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR SQL

Raw into column

CREATE or replace FUNCTION budget_function(num integer)
RETURNS TABLE(budget bigint, dub_date text)
LANGUAGE plpgsql
AS $function$
begin

    return query
        SELECT SUM(t1.budget) budget,
               string_agg(TO_CHAR("bud_date",'YYYY-MM-DD'),'-') date
        FROM (
          SELECT *, ROW_NUMBER() OVER(ORDER BY "bud_date") rn
          FROM budget_table
        ) t1
        GROUP BY (rn - 1)/num
        ORDER BY (rn - 1)/num;
    
end
$function$
;
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #Raw #column
ADD COMMENT
Topic
Name
7+8 =