Good day! Please help me transfer the region column from row to col (put the value of forecast and region with the value of quantity), given that there can be any number of regions, I will be very grateful for useful articles. If it is not difficult to comment, since I still have nothing to do.
Request:
SELECT products.name product, products.price, regions.region, SUM(forecasts.quantity) AS quantity, SUM(forecasts.forecast) AS forecast, forecasts.start_date FROM forecasts LEFT JOIN products ON products.id = forecasts.product_id LEFT JOIN regions ON regions.id = forecasts.region_id WHERE forecasts.start_date = "2016-11-14" GROUP BY forecasts.product_id, forecasts.region_id; After that, the resulting data is displayed in the following table:


столбец region из row перенести в col (поместить в него значение forecast и region со значением quantity)is not clear - Alexey Shimanskyid/region/total_forecast/total_quantityand update the table once in N time. - Alexey Shimansky