case statement trying to aggregate data in case statement using aggregate functions
<pre><code>  SELECT c.DESCRIPTION,
         fobt.OBJECT_ID,
         fobt.FA_OBJECT_TRANS_VALUE_TYPE,
         fobt.OBJECT_TRANSACTION_ID,
         fobt.OBJECT_TRANSACTION_DATE,
         fobt.AMOUNT,
         fobt.FA_YEAR,
         fobt.FA_PERIOD,
         SUM(fobt.AMOUNT) OVER(
                                PARTITION BY fobt.
                                ORDER BY fobt., fobt.OBJECT_TRANSACTION_DATE
                              ) AS RUNTOTAL,
         DENSE_RANK() OVER(
                           PARTITION BY fobt.OBJECT_ID
                           ORDER BY fobt.FA_YEAR DESC
                          ) RK1,
         DENSE_RANK()
             OVER(
                  PARTITION BY fobt.OBJECT_ID, c.DESCRIPTION
                  ORDER BY
                      fobt.FA_YEAR,
                      fobt.FA_PERIOD,
                      c.DESCRIPTION DESC
                 )
             rnk2
    FROM FA_OBJECT_TRANSACTION fobt
         INNER JOIN (SELECT DISTINCT COMPANY,
                                     OBJECT_ID,
                                     OBJECT_TRANSACTION_ID,
                                     CODE_C
                       FROM FA_) FT
             ON     fobt. = FT.
                AND fobt. = FT.OBJECT_TRANSACTION_ID
         INNER JOIN CODE_C c
             ON     FT.CODE_C = c.CODE_C
                AND FT.COMPANY = c.COMPANY
   WHERE     fobt.OBJECT_ID = 12345
         AND fobt.FA_ IN ('Depreciation')
ORDER BY 2, 4
</code></pre>

<p>I'm trying to fix the DENSE_RANK for OBJECT_ID, DESCRIPTION, YEAR AND PERIOD. There is only one object id = 1234 but there are 2 locations (Rotterdam and South Windsor).  Equipment A was logged in location South Windsor  from 5/2015 to 3/2016  and then transferred to Rotterdam on 4/2016. I will like to have a DENSE_RANK by PARTITION by OBJECT_ID and LOCATION but the order by is not working properly.  I would like to take the latest date(year and month by location of that piece of equipment.  For example, Equipment A on 3/2016 at location South Windsor would be ranked 1 because it is the latest date at that location and then transferred to location Rotterdam on 4/2016 and that would also get tagged ranked 1 because it changed location.  Below are the current results and second example is the desired result.</p>