salix/print/templates/reports/supplier-campaign-metrics/sql/buys.sql

33 lines
770 B
MySQL
Raw Normal View History

2020-12-16 07:05:41 +00:00
SELECT
2020-12-18 09:08:51 +00:00
b.id AS buyId,
b.itemFk,
b.entryFk,
CAST(b.buyingValue AS DECIMAL(10,2)) AS price,
b.quantity,
i.id,
i.description,
i.name AS itemName,
i.subName,
i.size AS itemSize,
i.typeFk AS itemTypeFk,
i.tag5,
i.value5,
i.tag6,
i.value6,
i.tag7,
i.value7,
i.tag8,
i.value8,
i.tag9,
i.value9,
i.tag10,
i.value10,
it.id,
it.workerFk,
it.categoryFk,
it.code AS itemTypeCode
FROM buy b
JOIN item i ON i.id = b.itemFk
JOIN itemType it ON it.id = i.typeFk
WHERE b.entryFk IN(:entriesId) AND b.quantity > 0
ORDER BY i.typeFk , i.name