# `Sp_Sales_SalesAnalysiseOfCustomer` (procedure) > 客户销售分析表 - **Type:** PROCEDURE - **Deterministic:** NO - **SQL data access:** CONTAINS SQL ## Parameters | # | Mode | Name | Type | |---|---|---|---| | 1 | IN | `tStartDate` | `datetime` | | 2 | IN | `tEndDate` | `datetime` | | 3 | IN | `sBrId` | `varchar(100)` | | 4 | IN | `sSuId` | `varchar(100)` | | 5 | IN | `sLoginId` | `varchar(100)` | | 6 | IN | `bFilter` | `varchar(5000)` | | 7 | IN | `pageNum` | `int` | | 8 | IN | `pageSize` | `int` | | 9 | OUT | `totalCount` | `int` | | 10 | IN | `countCloumn` | `varchar(5000)` | | 11 | OUT | `countMapJson` | `longtext` | | 12 | IN | `sFilterOrderBy` | `varchar(5000)` | | 13 | IN | `sGroupby_select_sql` | `varchar(5000)` | | 14 | IN | `sGroupby_group_sql` | `varchar(5000)` | ## Body _Body is not pre-cached. To inspect: `mysql --defaults-file=~/.my.cnf -e 'SHOW CREATE PROCEDURE `Sp_Sales_SalesAnalysiseOfCustomer`'`._ ## Narrative **Business context:** 销售管理 → 销售分析(客户角度) → 销售分析表(客户) — paged sales analysis report grouped by customer. Cross-references the 销售订单 / 入库 / 送货 / 对账 / 开票 / 收款 chain so the user sees ordered, in-stocked, delivered, reconciled, invoiced and collected totals for every 客户 inside a date window. **What it does:** Builds temp table `SAS` seeded from `eleCustomer` (filtered by `Fun_GetLookCustomer(sLoginId,...)`), then progressively `UPDATE ... JOIN`s in counts and money columns: `viw_salSalesOrder` for ordered qty/money (restricted to the seven 销售订单 `sFormId` whitelist and `iOldNew=0`), `viw_pitproductinstore` + `viw_opsoutsideinstore` (excluding 余数库 warehouses and 备品 give-away qty) for instored no-tax money, `Viw_SalDeliverGoods` minus `Viw_SalRejectGoods` for delivered no-tax money, `viw_salsaleschecking` for reconciled money, `viw_SalSalesInvoice` for invoiced money and `viw_cahreceiptsum` for collected money. Computes 平均单价/数量, 占比 (`dRate`/`dPayRate`/`dBalanceRate`) via a sum from `tempSAS`, fills 上级客户名称 from `elecustomer.sSrcCustomerId`, drops zero-activity rows, then hands `SAS` to `Sp_Do_UpdateByPageSizeBefore` for `bFilter` paging and `countCloumn` summing. **Invocation:** Bound as the data-source of the 销售分析表(客户) form `gfm.sId=101251240115015848397842351` via `gdsconfigformmaster.sSqlStr` (literal proc name); module path 销售管理 → 销售分析(客户角度) → 销售分析表(客户). Loaded when the user opens the report. The 优化版 install script ships at `script/标版/optimize/Sp_Sales_SalesAnalysiseOfCustomer.sql`; the original install lives at `script/标版/30100101/Sp_Sales_SalesAnalysiseOfCustomer.sql` — verify which version is deployed.