-- ============================================ -- 查询绿纤明信店2025年12月毛巾总成本 -- ============================================ -- 门店ID: 1649328471923847187 (绿纤明信店) -- 月份: 202512 (2025年12月) -- -- 查询逻辑说明: -- 1. 只统计送出的记录(F_FlowType = 0) -- 2. 只统计有效记录(F_IsEffective = 1) -- 3. 时间优先使用送出时间(F_SendTime),如果为空则使用创建时间(F_CreateTime) -- 4. 统计字段:F_TotalPrice(总费用) -- ============================================ SELECT F_StoreId as 门店ID, SUM(F_TotalPrice) as 毛巾总成本, COUNT(*) as 记录数量, MIN(COALESCE(F_SendTime, F_CreateTime)) as 最早记录时间, MAX(COALESCE(F_SendTime, F_CreateTime)) as 最晚记录时间 FROM lq_laundry_flow WHERE F_IsEffective = 1 AND F_FlowType = 0 AND F_StoreId = '1649328471923847187' AND DATE_FORMAT(COALESCE(F_SendTime, F_CreateTime), '%Y%m') = '202512' GROUP BY F_StoreId; -- ============================================ -- 详细信息查询(查看具体记录) -- ============================================ SELECT F_Id as 记录ID, F_BatchNumber as 批次号, F_ProductType as 产品类型, F_Quantity as 数量, F_LaundryPrice as 清洗单价, F_TotalPrice as 总费用, F_SendTime as 送出时间, F_CreateTime as 创建时间, COALESCE(F_SendTime, F_CreateTime) as 统计时间 FROM lq_laundry_flow WHERE F_IsEffective = 1 AND F_FlowType = 0 AND F_StoreId = '1649328471923847187' AND DATE_FORMAT(COALESCE(F_SendTime, F_CreateTime), '%Y%m') = '202512' ORDER BY COALESCE(F_SendTime, F_CreateTime);