What they want is getting the average price from the Price and Price Quantity column (price/pricequantity), and marking the difference. If the price quantity doesn't match all 6 locations, then the flag is a Fail, If the price quantity match all 6 locations, then the flag is a Pass.
CodePudding user response:
In SQL use CASE WHEN
SELECT *, CASE
WHEN PriceQuantity = 10 THEN 'true'
ELSE 'false'
END AS Flag
FROM table
CodePudding user response:
Sorry the question was different. It is the same method to apply but with the calculation :
SELECT *,
CASE
WHEN ((Price/Qyt) = AVG(Price/Qyt)) THEN 'true'
ELSE 'false'
END AS Flag
FROM table
GROUP BY Item, Site, Date, Price, ... (and others column but not Flag)