I would like to count all the repetitions of the maximum values from the profit column for all asset (they repeat, and I want to choose the best result from each unique repetition), and finally group the results according to the value of the strategy column.
I use DBD::CSV for Perl, its using SQL statements like here: http://search.cpan.org/~rehsack/SQL-Statement-1.412/lib/SQL/Statement/Syntax.pod
But that is not important. What I care about most is to improve my syntax, and I should deal with the rest of the matter.
SELECT COUNT(*) AS dupa
FROM (SELECT asset, strategy, MAX(profit)
FROM a1.csv
GROUP BY strategy);
Output: Bad table or column name: 'SELECT' is a SQL reserved word!
Another example:
SELECT * AS xxx FROM (SELECT strategy, profit FROM a1.csv GROUP BY strategy)
Output: Bad table or column name: 'SELECT' is a SQL reserved word!
It's only example. I tried different combinations and there are always errors. I wanted to ask what is wrong in my syntax?