我有一個查詢它得到誰已經作出了購買該產品的當天客戶名單SQL查詢每日銷售特定產品
select Customer.customerName, sum(InvoiceDetail.itemPrice * InvoiceDetail.itemQuantity) as dailyPurchase from Invoice
inner join InvoiceDetail on Invoice.invoiceID = InvoiceDetail.invoiceID
inner join Customer on Invoice.customerID = Customer.customerID
inner join Item on InvoiceDetail.itemID = Item.itemID
inner join Branch on Branch.branchID = Invoice.branchID
inner join Region on Region.regionID = Branch.regionID
where
Invoice.inactive = 0 and InvoiceDetail.inactive = 0
and Item.itemTypeID = 3
and Region.regionCode = 'CR'
and cast(Invoice.invoiceDate as date) = convert(date, '01/08/2016', 103)
group by Customer.customerName
我需要的是一個每月表中列出當前所有日期的列表,列出至少購買了一次產品的所有客戶。它應該類似於similar to this image here。
任何幫助如何開始或如何獲得理想的結果的一般想法,非常感謝。謝謝!從結果
樣本數據:
customerName dailyPurchase
AGH COMMUNICATIONS 450.00
ARIEL AMARCORD SHOP 285.00
AKN COMMUNICATION 300.00
AWSDAC TELECOMMUNICATION 2850.00
BARLEY MOBILE & SERVICES 285.00
Table Structure - 對不起,我不知道一個簡單的方法來複制此。
請提供表格結構以及可能的樣品數據。 – Esty
@TanjimRahman添加到帖子中。 – superflyingcrap
你在做什麼「報告」?只是出口到Excel?最簡單的方法是將paste複製到excel中並使用數據透視表。如果你需要每天都有_every_,你需要創建一個日曆或統計表 - 你能創建表嗎? –