我从几个表中选择:
SELECT SUM(S2.F64) as sumAll
FROM someTABLE1 S1
LEFT OUTER JOIN someTABLE2 S2 ON S2.F32 = S1.F32
WHERE S2.F01 = '1006'
and S2.F68='ORDER' AND S1.F67='ITEM'
现在我想从另一个选择中获取 S1.F01 的值:像这样
SELECT S3.F01
FROM someTABLE3 S3
WHERE "something..."
所以我想要这样的东西:
SELECT SUM(S1.F64) as sumAll, S3.F01
FROM someTABLE3 S3
LEFT OUTER JOIN someTABLE1 S1 ON S1.F01 = S3.F01
LEFT OUTER JOIN someTABLE2 AS S2 ON S1.F32 = S2.F32
WHERE S1.F01 = S3_F01
and S2.F1068='ORDER' AND S1.F1067='ITEM'
但是,我想获取 S3 中的所有项目,并在 sumAll 中填充条件匹配的列。
所以我想要这样的东西(伪代码):
SELECT * from S3
FOR EVERY (S3.F01)
{
SELECT * FROM S1
if(S1.F1067='ITEM')
RETURN S3 AND SUM(S1.F64)
ELSE
RETURN S3
}
反正有这样做吗?