List:General Discussion« Previous MessageNext Message »
From:Arup Rakshit Date:July 19 2014 12:13pm
Subject:Re: DISTINCT not working inside a CASE statement.
View as plain text  
On Saturday, July 19, 2014 02:56:24 PM Reindl Harald wrote:

> > 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?

Ohh. God. So simple it is -

MariaDB [tutorial]> select name, sum(cost) AS cost_sum from prices group by 
name;
+------+----------+
| name | cost_sum |
+------+----------+
| A    |     6700 |
| B    |    12000 |
| C    |     NULL |
+------+----------+
3 rows in set (0.01 sec)

Thanks.

-- 
================
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
Thread
DISTINCT not working inside a CASE statement.Arup Rakshit19 Jul 2014
  • Re: DISTINCT not working inside a CASE statement.Reindl Harald19 Jul 2014
    • Re: DISTINCT not working inside a CASE statement.Arup Rakshit19 Jul 2014