Arup Rakshit DISTINCT not working inside a CASE statement.
Jul 19, 2014; 18:15
Arup Rakshit
DISTINCT not working inside a CASE statement.
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
-- ===============Regards, Arup Rakshit ===============Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
--Brian Kernighan
-- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/mysql
Jul 19
Reindl Harald Re: DISTINCT not working inside a CASE statement.
Jul 19, 2014; 14:56
Reindl Harald
Re: DISTINCT not working inside a CASE statement.
Jul 19
Arup Rakshit Re: DISTINCT not working inside a CASE statement.
Jul 19, 2014; 18:43
Arup Rakshit
Re: DISTINCT not working inside a CASE statement.
Search
Lasso Programming
This site manages and broadcasts several email lists pertaining to Lasso Programming and technologies related and used by Lasso developers. Sign up today!