0
我有一個groupby和sum表,用於顯示當前股票(它對所有股票條目進行分組和彙總)。我現在要顯示每個groupby組的最新輸入日期。分組並顯示該組的最新入場日期
這裏是我的工作:
-------------------------------------------------------------------
ProductID | Color | Timestamp | Quantity | RowID |
-------------------------------------------------------------------
25 | Red | 10/10/10 06:22:15 | 250 | 1 |
-------------------------------------------------------------------
32 | Green | 10/10/10 06:23:45 | 100 | 2 |
-------------------------------------------------------------------
$query = "SELECT productid, color, SUM(Quantity) AS TotalQuantity FROM inventory GROUP BY productid, color";
$result = mysql_query($query) or die(mysql_error());
// Table markup here
echo '<tr><td>'. $row['productid'] . '</td><td>' . $row['color']. '</td><td>'. $row['TotalQuantity'];
// Table markup here
我嘗試使用最大值函數來獲取最大的rowid每個GROUPBY但它變得如此混亂!
我們走吧!謝謝Olivier! – cantaffordretail