|
SELECT a.*, b.截止, b.天利息
FROM 查询1 AS a LEFT JOIN 查询2 AS b ON b.lj<=a.欠天数;
union
SELECT a.*,(select 欠天数-sum(截止) from 查询2 where lj<=[欠天数]) AS 表达式1, 0
FROM newtt AS a;
查询2:
SELECT (select sum(截止) from 计息区段 where id<=a.id) AS lj, *
FROM 计息区段 AS a;
newtt:
SELECT 出库单明细.供应商ID, 出库单明细.增票日期, Sum(出库单明细.金额) AS 小计, Date()-[增票日期] AS 欠天数
into newtt FROM 出库单明细
GROUP BY 出库单明细.供应商ID, 出库单明细.增票日期, Date()-[增票日期]
HAVING (((出库单明细.供应商ID)=30))
ORDER BY 出库单明细.增票日期 DESC
WITH OWNERACCESS OPTION;
[ 本帖最后由 wwwwa 于 2008-1-3 14:44 编辑 ] |
|