I have a query that outputs address data:
SELECT ordernumber
, article_description
, article_size_description
, concat(NumberPerBox,' pieces') as contents
, NumberOrdered
FROM customerorder
WHERE customerorder.id = 1;
I would like the line above to be output NumberOrders(e.g. 50,000) divided by NumberPerBoxe.g. 2000 = 25 times.
Is there an SQL query that can do this, I don't mind using temporary tables to join if necessary.
I checked the previous questions, however the closest one: it
should be possible in mysql to repeat the same result
Only gave answers that give a fixed number of rows, and I need it to be dynamic depending on the value ( NumberOrdered div NumberPerBox).
As a result, I want:
Boxnr Ordernr as_description contents NumberOrdered
------+--------------+----------------+-----------+---------------
1 | CORDO1245 | Carrying bags | 2,000 pcs | 50,000
2 | CORDO1245 | Carrying bags | 2,000 pcs | 50,000
....
25 | CORDO1245 | Carrying bags | 2,000 pcs | 50,000
Johan source
share