Hi,
I’m working on a SQL query that returns multiple rows, and I want to add a final row that shows the total (e.g., sum of a column). I can do this using UNION ALL
, but the problem is that when I sort the result (e.g., by a column in a UI or tool), the summary row moves around.
Is there a way to make the summary row always stay at the bottom, regardless of how the user sorts the other columns?
I want my “Totalbelopp” to always stay in the bottom? Is this possible?
Thanks in advance!
Hi,
weeell…back in the day there was this TableOperations connector (it should be now free and included into every license)
and what we would do in Portal is use Machine workflow with “Datasource with Pagination and Filtering” schema as…well… the datasource 
Then that would give a whole structure in the start step that needed to be handeled in that TableOperations connector at the end.
But that also allowed us to put an extra row at the end with Totals and that row would be independant of any sorting
(It wasnt perfect becouse it would show on each page and Sum for the page…but there were ways around that too…like disabling the pagination sometimes

)
However, these days this connector is no longer recommended by Novacura as it is suspected to cause performance issues in our Cloud Servers.
Hope this helps!
B R
Ivan
1 Like
As Ivan says, do not use the table operator 
Maybe the HTML portlet if the table should be read only and non sortable. I did this for a customer yesterday (portal connect, but almost the same) with sums in the headers.
Or maybe a combo with the table and HTML in a vertical container? Or two tables, but the paginator is a bit ugly in my opinion, for that.
1 Like
Or..maybe
if you use a data source with pagination and filtering, without using the table operator. I think you might end up with a non sortable table, and you can control it manually. From our training:
1 Like
If you don’t want a distinct layout in your summary you can do it with SQL.
You have to order on data vs. summary first. Something like this:
with d as ( -- data
select 'A' as C1
, 3 as C2
from dual
union all
select 'C'
, 5
from dual
) -- with
select 'total' as C1
, sum(d.C2)
, 3 as SORTING
from d
union all
select d.*
, 2 as SORTING
from d
order by SORTING
, C1