0
I have the following scenario:
A table of products (tbl_prods
) that has among other fields the price of each product the type of products and the date of the transaction (dt_trns
). The guys can be typ1
, typ3
or typ3
.
I want a query that returns the sum of the prices of the products sold to a certain user in the year 2016 and in the month of Dec, and if the product is of type 2 (typ2) must have 40% discount.
That’s what I got but it ain’t working:
SELECT SUM(IF(prodtype='typ2',price*0.6,price)) FROM tbl_prods WHERE userId=123 AND YEAR(dt_trns)=2016 AND MONTH(dt_trns)=12;
Upshot = “You have an error in your SQL syntax; …”
Where am I going wrong?
It would not be this "." at the end "...12."?
– Wictor Chaves
there is no point. It was a paragraph point I will withdraw.
– zwitterion
You’re running that one
query
in your program or running in some database manager?– Roberto de Campos
I’m at the Workbench
– zwitterion
found, was missing quotes. YEAR(dt_trns)='2016' AND MONTH(dt_trns)='12'
– zwitterion