我想修改以下查询,以便为每个销售人员而不仅仅是一个销售人员汇总每月销售额。我相信它需要一个可循环字符串值的VB循环,但我不知道VB,所以如果你能提供详细信息我会很感激。
<contentSearch>
<configuration type="Sitecore.ContentSearch.ContentSearchConfiguration, Sitecore.ContentSearch">
<indexes hint="list:AddIndex">
<index id="sitecore_dev_index" type="Sitecore.ContentSearch.LuceneProvider.LuceneIndex, Sitecore.ContentSearch.LuceneProvider">
<param desc="name">$(id)</param>
<param desc="folder">$(id)</param>
<!-- This initializes index property store. Id has to be set to the index id -->
<param desc="propertyStore" ref="contentSearch/indexConfigurations/databasePropertyStore" param1="$(id)"/>
<configuration ref="contentSearch/indexConfigurations/devLuceneIndexConfiguration"/>
<strategies hint="list:AddStrategy">
<!-- NOTE: order of these is controls the execution order -->
<strategy ref="contentSearch/indexConfigurations/indexUpdateStrategies/syncMaster"/>
</strategies>
答案 0 :(得分:0)
相对简单的GROUP BY
查询,而不是所有这些子查询中的查询,应该可以更容易地计算出逻辑,并且可能也会提供更好的运行时性能。我没有看到你为什么需要VBA的原因。
SELECT
Format(SALES_RECEIPT.SALE_DATE, 'yyyy-mm') AS [Year-Month],
SALES_REP.rep_Name,
Sum(SALES_RECEIPT.SELLING_PRICE * SALES_RECEIPT.quantity),
Sum((Nz(SALES_RECEIPT.SELLING_PRICE,0) * Nz(SALES_RECEIPT.quantity,0))
* (Nz(SALES_RECEIPT.commission_percent, 100) * 0.001))
FROM
SALES_RECEIPT
INNER JOIN SALES_REP
ON SALES_REP.REP_ID = SALES_RECEIPT.REP_ID
WHERE SALES_RECEIPT.SALE_DATE BETWEEN #2015-1-1# AND #2050-12-31#
GROUP BY
Format(SALES_RECEIPT.SALE_DATE, 'yyyy-mm'),
SALES_REP.rep_Name;