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: 
```
  Declare @T table(id int) 
    insert into @T values (1),(2)
  Declare @T1 table(Tid int,fkid int,Amount int)
    insert into @T1 values (1,1,200),(2,1,250),(3,2,100),(4,2,25)

    Select SUM(t1.Amount) as amount,t1.fkid as id from @T t
 left outer join @T1 t1 on t1.fkid = t.id group by t1.fkid

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

```