how to access current/same/self row column value in sql query : Problem: I have companies who submits audit reports. I need to prepare a report column to show what is NextDueDate based on two conditions.

 1. if any FormF table has more than one rows, then one year from latest form's End date i.e. "ReportingTo"
 2. if only one FormF record found then one year from "RegistrationDate"

    >select F.[ID]
    	>,enty.[Title (Title)]
    	>,format(F.[ReportingFrom], 'MM/dd/yyyy') as 'ReportingFrom'
    	>,format(F.[ReportingTo], 'MM/dd/yyyy') as 'ReportingTo'
    	>,format(enty.[RegistrationDate], 'MM/dd/yyyy') as 'RegistrationDate'
    	>,CASE WHEN ((select count(F.ID) from [db_owner].[FormF] F where     >F.[EntityID]=F.[EntityID])>0) 
    	>	  THEN format(DATEADD(year, 1, (select top 1 F.[ReportingTo] from >[db_owner].[FormF] F where F.[EntityID]=F.[EntityID] order by F.ID desc))+1, >'MM/dd/yyyy') 
    	>ELSE format(DATEADD(year, 1, enty.[RegistrationDate])+1, 'MM/dd/yyyy') 
    	>END as 'AuditDueDate',F.[EntityID] from [db_owner].FormF F join entity >enty on F.[EntityID] = enty.ID where F.[EntityID]=F.[EntityID]


----------


    

[![enter image description here][1]][1]


  [1]: https://i.stack.imgur.com/jrpag.png