Q:

Max a Sum of a partition by

I have the below table. 
I would like to SUM hours and partition by id then take the Max hours per custid. Below is what I have so far. 
TableA
id    custid    projid   hours
 1      1010     Yellow    1
 1      1011     Yellow    2
 1      1012     Yellow    5
 1      1010     Yellow    5

SQL:
select SUM(HOURS)OVER (PARTITION BY ID ORDER BY cust) AS TOTAL_HRS
from tablea

Expected Output: The above SQL does not capture MAX hours
id    custid  projid  hours
 1      1010   Yellow  6

A:

Using SUM as an analytic function usually means that you want to find a sum while retaining all your original records.  But your expected output seems to imply an aggregation.  So, I suggest using GROUP BY, and then querying that to find the row with the highest hours.
WITH cte AS (
    SELECT id, custid, projid, SUM(hours) AS hours
    FROM yourTable
    GROUP BY id, custid, projid
)

SELECT *
FROM cte
ORDER BY hours DESC
WHERE rownum = 1

