38 lines
802 B
SQL
38 lines
802 B
SQL
WITH RECURSIVE numbers AS (
|
|
SELECT 1 n
|
|
UNION ALL
|
|
SELECT n + 1
|
|
FROM numbers
|
|
WHERE n < ?
|
|
)
|
|
SELECT ROW_NUMBER() OVER() labelNum,
|
|
b.itemFk,
|
|
i.name item,
|
|
b.id buyFk,
|
|
b.quantity,
|
|
b.packing,
|
|
b.entryFk,
|
|
o.code origin,
|
|
p.`name` producerName,
|
|
p.id producerFk,
|
|
i.`size`,
|
|
i.category,
|
|
i.stems,
|
|
i.inkFk,
|
|
ig.longName,
|
|
ig.subName,
|
|
i.comment,
|
|
w.code buyerName,
|
|
i.isLaid,
|
|
c.code company
|
|
FROM vn.buy b
|
|
JOIN vn.item i ON i.id = b.itemFk
|
|
LEFT JOIN vn.item ig ON ig.id = b.itemOriginalFk
|
|
JOIN vn.origin o ON o.id = i.originFk
|
|
LEFT JOIN vn.producer p ON p.id = i.producerFk
|
|
JOIN vn.itemType it ON it.id = i.typeFk
|
|
JOIN vn.worker w ON w.id = it.workerFk
|
|
JOIN vn.entry e ON e.id = b.entryFk
|
|
JOIN vn.company c ON c.id = e.companyFk
|
|
JOIN numbers num
|
|
WHERE b.id = ? |