看看“开发篇 - Foxtable编程 - 事件编程 - 调试技巧”
突然发现,问题真正所在....红色代码应该包含在or两个括号内...
select 住院ID,类别,sum(round(单价 * 用量,2)) as 金额 from [H_YIZ] where (开始日期 <= '" & d & "'and 停止日期 > '" & d & "' and 停止日期 is not null) or (开始日期 <= '" & d & "' and 停止日期 is null)
and 住院ID in (" & sql & ") GROUP BY 住院ID,类别