Question: Hallo,
I have a join table, said tableA and tableB. tableA have a column called Amount. tableB have a column called refID. I would like to total up the Amount column when refID having the same value. I was using SUM in my query, but it throw me an error:

```
ORA-30483: window  functions are not allowed here
30483. 00000 -  "window  functions are not allowed here"
*Cause:    Window functions are allowed only in the SELECT list of a query.
           And, window function cannot be an argument to another window or group
           function.

```

Here is my query for your reference:

```
select *
from (
       select SUM(A.Amount), B.refId, Rank() over (partition by B.refID order by B.id desc) as ranking
       from table A
       left outer join table B on A.refID = B.refID
)
where ranking=1;

```

May I know is there any alternate solution in order for me to SUM the Amount?

THanks @!

Answer: 
```
select 
  SUM(A.Amount), 
  B.refId
from table A
  left outer join table B on A.refID = B.refID
GROUP BY 
  B.refId

```
```
SELECT refid, sum(a.amount)
FROM table AS a LEFT table AS b USING (refid)
GROUP BY refid;

```