我的功能如下:
CREATE FUNCTION public.my_func(...)
RETURNS TABLE(a integer, b timestamp without time zone, c timestamp without time zone) AS
$BODY$
BEGIN
create temporary table t1 as
select ....
RETURN QUERY
WITH RECURSIVE x AS ( working with t1 ..... ) SELECT x.a, x.b, x.c where ....;
当我将其称为“select my_func(1,2,3)”时,它会在一列中返回数据:
result
-----------
(32, "7-dec-2016", "3-mar-2017")
我希望它在3个单独的列中返回它。怎么样?
答案 0 :(得分:2)
当您调用函数Map<Integer,String> tempMap = new TreeMap<Integer,String>();
Map<String,int []> resultMap = new LinkedHashMap<String,int[]>();
时,您的结果将作为一个字段中的记录。你需要运行:
hm.entrySet().stream().sorted(Map.Entry.comparingByValue(
new Comparator<int []>() {
public int compare(int [] a,int [] b) {
int sumA = a[0] + a[1];
int sumB = b[0] + b[1];
return sumA - sumB;
}
}));