I was trying to get the PIVOT
operation to work with MemSQL 6.7, but so far without success.
Based on the documentation I created a dummy table to match the example:
create table productionHistory(dayOfWeek varchar(10), itemsProduced int);
insert into productionHistory values ('Monday', 12);
insert into productionHistory values ('Saturday', 15);
insert into productionHistory values ('Sunday', 21);
Then I ran the example query:
SELECT "Items Produced" AS "Total Production by Day", Saturday, Sunday
FROM (
SELECT dayOfWeek, itemsProduced
FROM productionHistory
) AS pvt_subquery
PIVOT (
SUM(itemsProduced)
FOR dayOfWeek
IN ("Saturday", "Sunday")
) AS pvt_table;
But every time I run a query with PIVOT
I get the error:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'LIMIT 0, 200' at line 11