i have to select data from database and it envovles huge number of tables. each records will be returned 11 times . after i used distinct function on ID, it returns the result as:
ID amounts flow_no ...
1 40 1
2 20 1
2 25 2
2 10 3
3 10 1
3 15 2
4 20 1
code:
select distinct(deals.ID),cflows.amounts, events.flow_no, ...
from deals, cflows, events, ...
where ....
it pretty close to the result i want, then i have to sum up the amounts which have to be grouped by ID, but the problem is once i used group by, it will sum up all the record include those mutiple records. would i be able to only sum up the records as shown above. thanks a lot!
ID amounts flow_no ...
1 40 1
2 20 1
2 25 2
2 10 3
3 10 1
3 15 2
4 20 1
code:
select distinct(deals.ID),cflows.amounts, events.flow_no, ...
from deals, cflows, events, ...
where ....
it pretty close to the result i want, then i have to sum up the amounts which have to be grouped by ID, but the problem is once i used group by, it will sum up all the record include those mutiple records. would i be able to only sum up the records as shown above. thanks a lot!