1
Hi, I have a question in SQL. In the company system there are several registered products, and these products have different sales unit, that is, some are sold by Package, Box, Unit and etc... Every product is sold per UNIT = 1, but there are products that when it is sold in another unit of sale, there is a reduction in its price to '0.98', example: Product Screw:
Sales Unit - price factor_price
UN(Unit) - 1
CX(Box) - 1
EN(package) - 0.98
I wanted to do a following, if the sales units had price factor all '1', then I would ignore this product... But if any sales unit is equal to '0.98' I take '0.98' + the other sales units with the values. In the screw example: As there is a sales unit that has the price '0.98'(PT), I would take the '1'(CX) and the '1'(UN) also... But if the price factor of all sales units of this product were '1' then I ignored the same...
I tried this Code:
SELECT
produto.cd_prod,
produto.descricao,
unid_prod.qtde_unid,
unid_prod.fator_preco,
unid_vda
FROM
produto,
unid_prod
WHERE
unid_prod.cd_prod = produto.cd_prod
AND unid_prod.fator_preco IN('0.9800', '1')
However in this query the database brings the data of the 2 without filtering, even if the product does not have 0.9800 it brings...
could edit your answer and put an explanation ? It would be very good for the AP and for future users who have the same problem, know where the error.
– NoobSaibot
@wmsouza, I added an explanation to the reply. Thank you for your suggestion.
– Fernando