Skip to content

Instantly share code, notes, and snippets.

View leibovic's full-sized avatar

Margaret Leibovic leibovic

  • League
  • Toronto, ON
View GitHub Profile
@leibovic
leibovic / gist:2305880
Created April 4, 2012 21:35 — forked from rnewman/gist:2305471
Start of a query
Due to limitations of SQLite, we need to make a temp table for this:
CREATE TEMP TABLE duped_urls AS
SELECT url, SUM(visits) AS total, MAX(modified) AS latest, MAX(_id) AS winner
FROM history
GROUP BY url
HAVING count(url) > 1;
UPDATE history
SET visits = (SELECT total FROM duped_urls WHERE duped_urls.url=history.url),