Am 19.07.2014 13:45, schrieb Arup Rakshit: > Here is my simple table > > MariaDB [tutorial]> select * from prices; > +----+------+------+ > | id | name | cost | > +----+------+------+ > | 1 | A | 1200 | > | 2 | A | 2500 | > | 3 | A | 3000 | > | 4 | B | 5000 | > | 5 | B | 7000 | > | 6 | C | NULL | > +----+------+------+ > 6 rows in set (0.00 sec) > > I want it to give me data as > > name cost > A 6700 > B 12000 > C NULL > > But my query is not working - > > MariaDB [tutorial]> select name, CASE WHEN ISNULL(DISTINCT sum) THEN > sum(cost) > ELSE NULL END AS cost_sum > -> from prices group by name; > > ERROR 1064 (42000): You have an error in your SQL syntax; check the manual > that corresponds to your MariaDB server version for the right syntax to use > near 'DISTINCT sum) THEN sum(cost) ELSE NULL END AS cost_sum > from prices group by name' at line 1
how do you imagine that to work? what is the distinct in that context supposed to do?
signature.asc
Description: OpenPGP digital signature