I am trying to sum a total that i have from an aggregate function by using a nested select statement and then i have a group by at the end but I am getting an error that the keyword by is not expected.

Here is the code:

```
SELECT SUM(TOTAL) as CURTOTAL, SUM(LYTOTAL) as CURLYTOTAL
from
(select 
pf.*, ps.*, st.*, RANK() OVER (ORDER BY JULsaless desc) as TOTRANK,
 JANSALESS + FEBSALESS + MARSALESS + APRSALESS + MAYSALESS + JUNSALESS + JULSALES as TOTAL,
JANLYSAL + FEBLYSAL + MARLYSAL + APRLYSAL + MAYLYSAL + JUNLYSAL + JULLYSAL as LYTOTAL` 
from 
payssfile pf left joinpayssspec ps on pf.str#` = ps.str# and pf.item# = ps.item#  join storefile 
st on
pf.str# = st.str# where(year = 2015 and totaltype = '' and pf.str# =38))` group by pf.str#;`

```

then when I go to run that i get this message:

> 
> The keyword BY was not expected here. A syntax error was detected at
>  keyword BY. The partial list of valid tokens is FOR USE SKIP WAIT
>  WITH FETCH ORDER UNION EXCEPT OPTIMIZE.
> 
> 
>