SELECT * FROM ( SELECT ROW_NUMBER() OVER (PARTITION BY "PushNotificationMobileIdentifier"."UserId" ORDER BY "Id" DESC) AS "RowNumber","UserId","Id" FROM "PushNotification"."PushNotificationMobileIdentifier" WHERE "IsActive"='TRUE' ) k WHERE "RowNumber" >3
;WITH "TOPLAM" ("Kullanici") AS ( SELECT (COUNT("UserId"))-3 FROM "PushNotification"."PushNotificationMobileIdentifier" WHERE "IsActive"='TRUE' GROUP BY "UserId" HAVING COUNT("UserId")>3 ) SELECT SUM("Kullanici") FROM "TOPLAM"