Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
2.4 kB
3
Indexable
SELECT SQL_CALC_FOUND_ROWS product.id_product,
product.id_product_base,
product.id_package_type,
product.model,
product.is_blocked,
product.quantity,
product.quantity_locked,
product.price_mek,
product.price_minvk,
product.price_minvk_status,
product.price_minvk_date_validity,
product.price_pg1,
product.is_advertise,
product.is_prepared,
product.visibility,
product.status,
product.ean,
product.manufacturer_code,
product.order_durability,
product.order_need,
(SELECT `name`FROM product_lang WHERE product_lang.id_product=product.id_product and product_lang.id_lang='1')as name,
product.date_create created_at,
product.date_update_employee updated_at,
user_create.id_representative id_representative_create,
user_update.id_representative id_representative_update,
product.is_minvk_locked,
SUM(COALESCE(vkp.Menge,
0))SUM_Menge,
SUM(COALESCE(vkp.Roherloes,
0))SUM_Roherloes,
pnjoin.noteCount,
(SELECT `name`FROM package_type_lang WHERE package_type_lang.id_package_type=product.id_package_type and package_type_lang.id_lang=1)as package_type,
m.name manufacturer_name,
(SELECT `location`FROM `product_location`as plo WHERE plo.id_product=product.id_product and plo.`status`="10"ORDER BY plo.is_main DESC LIMIT 0,
1)as location FROM product LEFT JOIN product_lang lang on product.id_product=lang.id_product LEFT JOIN KHKVKBelegepositionen vkp on vkp.Artikelnummer=product.model LEFT JOIN KHKVKBelege vkb on vkp.BelID=vkb.BelID LEFT JOIN product_base pb on pb.id_product_base=product.id_product_base LEFT JOIN manufacturer m on m.id_manufacturer=pb.id_manufacturer LEFT JOIN(SELECT pn.id_product,
COUNT(pni.id_product_note_item)noteCount FROM `product_note_item`pni LEFT JOIN product_note pn ON pn.id_product_note=pni.id_product_note WHERE pn.status="10"AND pni.status="10"GROUP BY pn.id_product						
					)as pnjoin on pnjoin.id_product=product.id_product LEFT JOIN `user`user_create on user_create.id_user=product.id_user_create LEFT JOIN `user`user_update on user_update.id_user=product.id_user_update WHERE product.status='10'AND product.is_prepared='1'AND product.quantity>'0'AND pb.id_tax_class='1'AND product.status='10'AND vkb.delflag!='1'AND vkp.delflag!='1'AND vkb.Belegdatum>'2022-11-14'AND vkb.Belegdatum<='2023-11-14'AND vkb.Belegkennzeichen IN('VFR',
'VSD',
'VSL')AND product.quantity<='0'AND product.order_need<='5'GROUP BY product.model,
product.id_product ORDER BY SUM_Menge DESC LIMIT 0,
10
Leave a Comment