Хорошо, это подтверждение концепции. Просьба заметить, что это суммирует поля.
Надеюсь, теперь все стало яснее.
<html>
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>JSfiddle</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<script src="https://code.jquery.com/jquery-3.3.1.js" integrity="sha256-2Kok7MbOyxpgUVvAk/HJ2jigOSYS2auK4Pfzbm7uH60="
crossorigin="anonymous"></script>
</head>
<body>
<table>
<tr class="create-invoice-tr-body-items">
<td style="width: 12%;" class="ly-inv-preview-show-borders-cell">
<form>
<input class="inp-name" type="text" value="20" />
<input class="inp-name" type="text" value="20" />
<input class="inp-name" type="text" value="20" />
<input class="inp-name" type="text" value="20" />
<input class="inp-name" type="text" value="20" />
</form>
</td>
</tr>
</table>
</div>
<script>
$(document).ready(function () {
var sum = 0;
//perform loop accros all class elems
$('table tr td .inp-name').each(function (i, obj) {
//console.log(i, obj);
// cache varialbe
let $objVal = $(obj).val();
if ($objVal !== NaN && typeof $objVal !== "undefined") {
sum += parseFloat($objVal);
}
});
console.log(sum);
});
</script>
</body>
</html>
Необходимо создать агрегатную функцию, например,
CREATE AGGREGATE array_accum (anyelement)
(
sfunc = array_append,
stype = anyarray,
initcond = '{}'
);
затем
SELECT identifier, array_accum(value) AS values FROM table GROUP BY identifier;
HTH