| 54 | == Прикажување на продукт кој е прв додаден во системот за продажба и за него постојат најмалку нарачки кои биле направени од корисниците. |
| 55 | {{{ |
| 56 | INSERT INTO project.product_are_made_orders |
| 57 | (id_products, id_orders) |
| 58 | VALUES(5, 4); |
| 59 | SELECT |
| 60 | p.id AS product_id, |
| 61 | p.name AS product_name, |
| 62 | p.description AS product_description, |
| 63 | p.price AS product_price, |
| 64 | MIN(o.quantity) AS sold_quantity, |
| 65 | p.dateadded AS date_added |
| 66 | FROM |
| 67 | project.products p |
| 68 | LEFT JOIN |
| 69 | project.product_are_made_orders pamo ON p.id = pamo.id_products |
| 70 | LEFT JOIN |
| 71 | project.orders o ON pamo.id_orders = o.id |
| 72 | GROUP BY |
| 73 | p.id, p.name, p.description, p.price, p.dateadded |
| 74 | ORDER BY |
| 75 | sold_quantity, date_added |
| 76 | LIMIT 1; |
| 77 | }}} |
| 78 | |