I need to do 2 ranks in a table, one for all rows and one where Total Cum Production is greater than zero. Is there any way to do that with a Rank Function?
SELECT
LocationNumber
,[Date]
,Oil+Gas+Water as [TotalFluid]
,sum(Oil + Gas + Water ) over (partition by [LocationNumber] order by [Date] asc) as [CumTotalFluid]
,rank() over (partition by [LocationNumber] order by [Date] asc) as TABLE_DAY
,rank() over (partition by [LocationNumber] order by [Date] asc WHERE CumTotalFluid > 0) as Prod_DAY
FROM DV