Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
What is wrong?
The question works if I comment "if(c.country_id='1', 'SE', 'annat_land') as Land,"
Buyers:
LOAD * ;
SQL select cu.email as [Email Address],
max(o.created_at) as last_order_date,
cu.identity_number,
if(c.country_id='1', 'SE', 'other') as Country,
c.country_id
from carts c
left join customers cu on c.customer_id=cu.id
left join orders o on o.cart_id=c.id
where o.created_at>'2010-01-01 00:00:00.000'
and o.order_status_id>'100'
group by cu.email,cu.identity_number,c.country_id;
/Julia
Hi Julia,
The line where you create the Country (Land?) field is not an aggregated (eg SUM) or single (eg MAX) value, so that column needs to be included in the group by clause. Alternatively you can move the creation of that field into the preceding LOAD portion (eg LOAD*, if(country_id='1' ...)
flipside
Hi Julia,
The line where you create the Country (Land?) field is not an aggregated (eg SUM) or single (eg MAX) value, so that column needs to be included in the group by clause. Alternatively you can move the creation of that field into the preceding LOAD portion (eg LOAD*, if(country_id='1' ...)
flipside
Hi Julia,
Could you try this :
if(c.country_id=1, 'SE', 'annat_land') as Land,
I removed quotes
Hope that helps you
Martin
Thanks!