有人知道如何按日期分组制作重演数据吗?我想收集1天/周/月的所有交易。我想加入表Transaction
和Detail Transaction
,其中包含将在重演中显示的列。我坚持这个问题。任何回复都将不胜感激。
SELECT a.TransactionID,
a.Buyer_Code,
a.Date_Transaction,
b.NuggetID,
b.Qty,
b.Sub_Total,
a.Total_Price
FROM Transactions a,
DetailTransaction b
GROUP BY a.Date_Transaction
答案 0 :(得分:0)
你可能正在寻找。
SELECT a.TransactionID,
a.Buyer_Code,
a.Date_Transaction,
b.NuggetID,
QTY = SUM(b.Qty),
SubTotal = SUM(b.Sub_Total),
TotalPrice = SUM(a.Total_Price)
FROM Transactions a
JOIN DetailTransaction b On your keys
GROUP BY a.TransactionID,
a.Buyer_Code,
a.Date_Transaction,
b.NuggetID,