Skip to content

Instantly share code, notes, and snippets.

@rubysolo
Created July 1, 2009 21:08
Show Gist options
  • Select an option

  • Save rubysolo/139062 to your computer and use it in GitHub Desktop.

Select an option

Save rubysolo/139062 to your computer and use it in GitHub Desktop.
SELECT
MONTH(order.date),
SUM(CASE MONTH(order.date) WHEN 1 THEN detail.price * detail.quantity ELSE 0 END) AS JanuarySales,
SUM(CASE MONTH(order.date) WHEN 2 THEN detail.price * detail.quantity ELSE 0 END) AS FebruarySales,
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment