2014/10/08 11:38 -0700, Jan Steinman
However, this pattern will often result in numerous empty columns -- empties
that would not be there had the table not been pivoted.
2014/10/08 16:42 -0500, Peter Brawley
MySQL stored procedures are less incomplete, and can do it,
On 2014-10-08 1:38 PM, Jan Steinman wrote:
I often use CASE WHEN ... to pivot tables. For example, splitting sales data by
year:
SELECT
s_product.name AS `Product`,
SUM(CASE WHEN YEAR(sales.Date)='2007' THEN sales.Total ELSE NULL END) AS
`2007`,
SUM(CASE WHEN YEAR(sales.Date)
I often use CASE WHEN ... to pivot tables. For example, splitting sales data by
year:
SELECT
s_product.name AS `Product`,
SUM(CASE WHEN YEAR(sales.Date)='2007' THEN sales.Total ELSE NULL END) AS
`2007`,
SUM(CASE WHEN YEAR(sales.Date)='2008' THEN sales.Total ELSE NULL END) AS
`2008
A big thanks to Johan, who pointed me in the right direction.
I had indeed to fix a where clause, but in the end al went very well.
BR, hans.
Johan De Meersman schreef op 07-10-14 om 16:10:
- Original Message -
From: "Trianon 33"
Subject: Need a short directive
Values from yearand
We will tend to use binary backups (Xtrabackup) for full consistent dataset
restore (think slave provisioning and disaster recovery) and logical
backups to perform single table restores in the event that a rollback may
need to occur if someone drops a table or carries out an insane update. We
will