1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
| SELECT A.Item_parent_id, A.Discount_oc_id, A.Price_priority
, A.Public_price, A.Public_cashback
, A.Discount_price, A.Discount_amount, A.Discount_cashback
, B.Item_params_value1
, DateDiff(Current_timestamp,B.Item_date_created)
, A.Brand_ID, B.Brand_Designation, B.Brand_img
, A.Level1_id, B.Level1_designation_fr, B.Level1_designation_rw
, A.Level2_id, B.Level2_designation_fr, B.Level2_designation_rw
, A.Level3_id, B.Level3_designation_fr, B.Level3_designation_rw
FROM (
SELECT Item_parent_id, Discount_OC_ID
, Price_priority, Brand_id, Level1_id, Level2_id, Level3_id
, Public_price, Public_cashback
, Discount_price, Discount_amount, Discount_cashback
FROM td_items_parents_prices
WHERE Price_isvalidated=2 /*CLAUSE*/
ORDER BY Price_priority DESC ) A
INNER JOIN td_items_parents_list1 B ON A.Item_parent_ID=B.Item_parent_ID
GROUP BY A.Item_parent_id
ORDER BY A.Price_priority DESC
/*LIMIT*/; |