SELECT DATE(o.OrderDate), 
od.GiftTrakNumber, 
COUNT (DISTINCT o.OrderID) AS Orders, 
COUNT(od.Quantity) AS `lines`, 
SUM(od.Quantity) AS lineqty, 
SUM(od.Quantity * od.ProductPrice) AS sales, 
SUM(od.Quantity * od.Vendor_price) AS cogs, 
od.QtyOnPackingSlip 
FROM orders o
JOIN orderdetails od 
	ON o.OrderID = od.OrderID
WHERE od.GiftTrakNumber NOT IN (0,99) AND DATE(o.OrderDate) > '2020-01-01' 
AND o.Order_Entry_System != 'MARKETPLACE'
AND od.ProductCode != 'Restock'
GROUP BY DATE(o.OrderDate), od.GiftTrakNumber, od.QtyOnPackingSlip 
ORDER BY DATE(o.OrderDate), od.GiftTrakNumber, od.QtyOnPackingSlip