From c15c58dafd6e2cc60a08e3ee704a7df950b97d1d Mon Sep 17 00:00:00 2001 From: Andreas Kristiansen <6977712+AndreasK79@users.noreply.github.com> Date: Wed, 17 Jul 2024 10:55:04 +0200 Subject: [PATCH] Remove duplicates --- application/models/Accumulate_model.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/application/models/Accumulate_model.php b/application/models/Accumulate_model.php index c32929445..fe528bab3 100644 --- a/application/models/Accumulate_model.php +++ b/application/models/Accumulate_model.php @@ -536,9 +536,10 @@ class Accumulate_model extends CI_Model $sql .= " GROUP BY 1) as z ) - SELECT DISTINCT COUNT(grid) OVER (ORDER BY year) as total, year - FROM firstseen - ORDER BY 1 + , z as ( + SELECT grid, row_number() OVER (partition by grid ORDER BY grid asc, year asc) as rn, year + FROM firstseen + ) select DISTINCT COUNT(grid) OVER (ORDER BY year) as total, year from z where rn = 1 "; return $sql;