YS
Но проблема именно в этом, сравните свои функции.
Вот тут названия полей корректны (и совпадают):
select distinct on (x."UserId", x."PhoneNumber", x."CountryCode") x."UserId", x."PhoneNumber", x."CountryCode", x."ContactName", x."Email", x."Company", x."JobTitle", x."AccountName", x."ContactGroup", x."CreatedAt", x."ContactOrigin"
from jsonb_to_recordset(data) as x(
"Id" int8,
"UserId" int8,
А вот тут — нет:
select
x."LoanId",
x."CustomerId",
x."LoanCount",
x."IsFirstLoan",
x."TotalIncome30",
x."TotalIncome60",
x."TotalIncome90",
x."TotalIncome180",
x."MainDebt30",
x."MainDebt60",
x."MainDebt90",
x."MainDebt180",
x."Delay30",
x."Delay60",
x."Delay90",
x."Delay180",
x."TotalIncomeCurrent",
x."MainDebtCurrent",
x."DelayCurrent",
x."CreatedDate",
x."StatisticDate"
from
jsonb_to_recordset(data) as x(
LoanId int8, -- где кавычки?!
CustomerId int8, -- где кавычки?!




