I have been searching the Web and SO without finding an answer to a rather simple question. The thing may be that I don’t know how to phrase it. Here is what I am trying to do.
I have a MySQL table with multiple SKUs (let’s call it skutable) and for each line I have a certain number of columns describing the SKU : name, price, price-range (I have 4 different price-ranges), week of publishing, … and a certain number of columns describing the performance of the SKU : revenues, margin, quantitysold …
What I would like to do if writing an SQL query that allows me to display (with PHP) a table that would show for example :
In line : weeks / In column : price-ranges / In the cell : the % of SKUs belonging to a certain price-range for a given week.
or another example would be :
In line : weeks / In column : price-ranges / In the cell : the % of qty sold for SKUs belonging to a certain price-range for a given week.
I’ve been trying to write a query that would provide an array of multiple-arrays as a result but it doesn’t seem to work.
If anyone knows how to do ?
thanks,
E.
Your SQL query has to return one row (% of SKU, % of quantity sold) for each combination: week * price-range * another-dimension-if-needed. Then do your “tabular / cross tab” logic in PHP by looping through the results, or looping from min to max for each dimension and looking for the corresponding data in results.