PostgreSQL Query Troubles

wxdqz

New Member
I'm hoping someone can shed some light on how to resolve the issues with the below query. The error message is explanatory enough, I need to group or aggregate on stats.last_visit (datatype TIMESTAMP). Problem is, doing that destroys the goal of the query. I need to get a listing of the counts for each day of the month and grouping on the timestamp will give me an ungrouped listing. Any ideas for work arounds? Thanx!!

  SELECT
    COUNT(id) AS count,
    DATE_PART('day', last_visit) AS day,
    DATE_PART('month', last_visit) AS month
  FROM
    stats
  WHERE
    last_visit LIKE '2001-12%' AND
    referer != '' AND
    referer != '-' AND
    link_type = 'external'
  GROUP BY
    day
  ORDER BY
    last_visit ASC

-geoff
 
Back
Top