【发布时间】:2014-05-08 13:44:38
【问题描述】:
如何通过以下查询使用分组功能?
实际上我尝试加入(内连接)两个包含 2 个字段的表。
没关系:
t1.fiels6 = t2.field7
这在内部连接函数中不起作用。因此我在 where 函数中使用了它:
t1.field8 = SUBSTRING(t2.field9,1,INSTR(t2.field9,'-') - 1)
and (INSTR(t2.field9,'-') - 1) < 14
and (INSTR(t2.field9,'-') - 1) > 0
我的主要目标是获取每组 t2.field2 的 avg((t1.field3 * t2.field4)) 和 stddev((t1.field3 * t2.field4))
select
t1.field1 as f1, t2.field2 as f2,(t1.field3 * t2.field4) as f5
from
pub.table1 t1, pub.table2 t2
where
t1.fiels6 = t2.field7
and t1.field6 = 'XXX'
and t1.field8 = SUBSTRING(t2.field9,1,INSTR(t2.field9,'-') - 1)
and (INSTR(t2.field9,'-') - 1) < 14 and (INSTR(t2.field9,'-') - 1) > 0
【问题讨论】: