0

I'm getting the Truncated incorrect INTEGER value error in MYSQL, when I execute the code below. I know the logic doesn't make much sense and that will change and I am more concert about the error. I have tried casting the whole case statement but I still get the same error message.

Here is the original statement

select ( count(case when v.SalesDate = v.SalesDate then v.Surname end) ) as x
from finaljoinalldata v group by date(v.SalesDate) order by date(v.SalesDate);

I have tried also

select ( count(CAST(case when v.SalesDate = v.SalesDate then v.Surname end) AS SIGNED) ) as x
from finaljoinalldata v group by date(v.SalesDate) order by date(v.SalesDate);

Any help will be appreciated. Thanks

4

1 回答 1

0

你的说法没有道理。为什么你还有这个case条件?这是多余的——除非您专门检查NULL值。

这应该有效:

select count(v.Surname) as x
from finaljoinalldata v
group by date(v.SalesDate)
order by date(v.SalesDate);

当我看到 agroup by并且group by列不在select.

于 2015-04-17T23:31:18.197 回答