I have to write a question that looks a little too complicated for me, with the sample record I have the order_products table:
| ORDER_PRODUCTS_ID (auto) | PRODUCT_ID | PRICE | QUANTITY | 1 | 2 | 100 | 2 | 2 | 2 | 100 | 3 | 3 | 2 | 50 | 1 | 4 | 3 | 200 | 4 | 5 | 3 | 200 | 2
I need a query for relations, where I can get a summary of the group of products most often purchased based on product IDs and prices (because in each product There may be different prices in the order that you see, for example) I need to have the result:
PRODUCT_ID | QUANTITY_SUM | PRICE | Total SUM PRICE 3 | 6 | 200 | 400 2 5 | 100 | 200 2 1 | 50 | 50
I'm trying like a question:
select the value, product_id, quantity (amounts) as quantity, volume * quant_sum By value_s_m_pricks, the value of the value by dr_orders_products group by Product_id, quantity_sum desc
but gives me an error: 'quantity_sum unknown column' was trying anything like this: total price As the value
value, product_id, volume (quantity) quantity as quantity_sum, Price * (from the dr_orders_products select the product SUM (quantity) where product_id = product_id ans = value) by the value order by product_id, quantity_sum desc
from the group_products group, but the result worng some high values I am unable to call a nickname field, I have the option to call Statement, so that you can use the Something like this: select
quality_sum
to call them as the original name. But if you are doing a SUM
in the volume area, then you only need to use the same quantity to complete the total quantity.
No comments:
Post a Comment