IPAM sql report to get Default Gateway* from subnet address

Version 1

    Not sure if others have already done this work but after hours of not finding any cut/paste solutions I sat down to write an advanced SQL report including finding a subnet's gateway address. Now this assumes you have the default gateway set for the first available IP as we do and if not then it would be a custom field. Not sure why this is not a built-in field in IPAM?

     

    SELECT address, (PARSENAME([Address], 4)) + '.' + (PARSENAME([Address], 3)) +'.' +  (PARSENAME([Address], 2)) + '.' + CAST(CAST((PARSENAME([Address], 1)) AS int)+1 AS nchar) as 'Gateway'

    FROM IPAM_Groupreportview

    ORDER BY CAST(PARSENAME([Address], 4) AS INT),

             CAST(PARSENAME([Address], 3) AS INT),

             CAST(PARSENAME([Address], 2) AS INT),

             CAST(PARSENAME([Address], 1) AS INT)