Skip to content

Instantly share code, notes, and snippets.

@basicxman
Created November 30, 2011 02:02
Show Gist options
  • Select an option

  • Save basicxman/1407638 to your computer and use it in GitHub Desktop.

Select an option

Save basicxman/1407638 to your computer and use it in GitHub Desktop.
SELECT days.*, name, SUM(value) AS total_points FROM "days" LEFT JOIN points ON points.day_id = days.id LEFT JOIN tasks ON tasks.id = points.task_id WHERE "days"."user_id" = 2 AND (value IS NOT NULL) GROUP BY task_id, date ORDER BY date;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment