You can try something like this (with your example):
Table
create table test ( row_id int, id int, total decimal(15,2) ); insert into test values (6395, 1509, 112), (22986, 1509, 112), (1393, 3284, 40.37), (24360, 3284, 40.37);
Query
with distinct_records as ( select distinct id, total from test ) select a.id, b.actual_total, array_agg(a.row_id) as row_ids from test a inner join (select id, sum(total) as actual_total from distinct_records group by id) b on a.id = b.id group by a.id, b.actual_total
Result
| id | actual_total | row_ids | |------|--------------|------------| | 1509 | 112 | 6395,22986 | | 3284 | 40.37 | 1393,24360 |
Explanation
We do not know what reasons for orders and totals appear more than once with different row_id. Thus, using the common table expression (CTE), using the phrase with ... , we get a separate identifier and the final value.
At CTE, we use this different data to do a totalization. We append the identifier in the source table with aggregation by individual values. Then we separate the row_ids comma to make the information look cleaner.
SQLFiddle example
http://sqlfiddle.com/#!15/72639/3