I have a table with example data as shown below.
word | last_seen | first_seen | count
-----------|------------|------------|------
definition | 2014-09-08 | 2012-01-02 | 15
definition | 2014-10-11 | 2013-05-12 | 35
attribute | 2013-07-23 | 2010-06-29 | 22
I'm wanting to to an in-place aggregation of the data, hopefully just using SQL, where the data for repeated words is such that I end up with MAX(last_seen)
, MIN(first_seen)
, and SUM(count)
.
word | last_seen | first_seen | count
-----------|------------|------------|------
definition | 2014-10-11 | 2012-01-02 | 50
attribute | 2013-07-23 | 2010-06-29 | 22
I know I can see the results of the aggregation with the following:
SELECT
word,
MAX(last_seen) AS last_seen,
MIN(first_seen) AS first_seen,
SUM(count) AS count
FROM
words
GROUP BY word;
However, I don't just want to see the resulting aggregation... I want to actually update the words
table, replacing the rows that have duplicate word
column entries with the aggregated data.