Office中国论坛/Access中国论坛
标题:
[求助]合并的问题
[打印本页]
作者:
zzll15888
时间:
2006-9-30 15:23
标题:
[求助]合并的问题
在实际运用中出现的问题,请问:如何才能将“查询1”和“查询2”的相关字段放在一个“新的查询”中,并生成如下的结果。请大家指点!!!
<COLGROUP>
<COL style="WIDTH: 48pt" span=5 width=64>
字段1
字段3
日均1
字段3
日均2
abc
0
5.044444
1
5.155556
def
0
13.45556
1
8.855556
[attach]20666[/attach]
作者:
一点通
时间:
2006-9-30 17:16
SELECT 表1.字段1, DLookUp("字段3","表1","字段3='" & 0 & "'") AS 字段3, DSum("字段4","表1","字段1&字段3='" & [字段1] & 0 & "'") AS 总计0, [总计0]/90 AS 日均, DLookUp("字段3","表1","字段3='" & 1 & "'") AS 字段31, DSum("[字段4]","表1","[字段1]&[字段3]='" & [字段1] & 1 & "'") AS 总计1, [总计1]/90 AS 日均1
FROM 表1
GROUP BY 表1.字段1, DLookUp("字段3","表1","字段3='" & 0 & "'"), DLookUp("字段3","表1","字段3='" & 1 & "'");
作者:
zzll15888
时间:
2006-9-30 20:40
OK!谢谢“一点通”,这是最好的节日礼物!祝ACCESS交流论坛越办越好,越办越红火!!!
作者:
zzll15888
时间:
2006-10-16 06:04
再请教“例子”中,如果按所需时间段来合并查询,应如何写?(此例子按“月”查询)[attach]20926[/attach]
作者:
一点通
时间:
2006-10-16 16:43
SELECT 表1.字段1, Format([字段2],"yyyy/mm") AS 年月, DLookUp("字段3","表1","字段3='" & 0 & "'") AS 字段3, DSum("字段4","表1","字段1&字段3='" & [字段1] & 0 & "'") AS 总计0, [总计0]/90 AS 日均, DLookUp("字段3","表1","字段3='" & 1 & "'") AS 字段31, DSum("[字段4]","表1","[字段1]&[字段3]='" & [字段1] & 1 & "'") AS 总计1, [总计1]/90 AS 日均1
FROM 表1
GROUP BY 表1.字段1, Format([字段2],"yyyy/mm"), DLookUp("字段3","表1","字段3='" & 0 & "'"), DLookUp("字段3","表1","字段3='" & 1 & "'");
欢迎光临 Office中国论坛/Access中国论坛 (http://www.office-cn.net/)
Powered by Discuz! X3.3