Hello, I have a question in SQL. In the company's system there are several products registered, and these products have different sales unit, ie some are sold by Package, Box, Unit and etc ... Every product is sold for UNIT = 1, but there are products that when sold in another sales unit, there is a reduction in its price to '0.98', for example: Product Screw:
Sales unit - price_factor
UN (Unit) - 1
CX (Cash) - 1
PT (Package) - 0.98
I wanted to do a following, if the sales units had the price factor all '1' then I would skip this product ... But if any sales unit equals '0.98' I get the '0.98' + other sales units with the values. In the example of the screw: As there is a unit of sale that has the price '0.98' (PT), I would get the '1' (CX) and the '1' (UN) as well ... But if the price factor of all the sales units of this product was '1' then I would ignore the same ...
I've 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')
But in this query the database brings the data of the 2 without filtering, even if the product does not have 0.9800 it ...