在MS Access中,我已连接到具有只读访问权限的外部Oracle数据库表。该表跟踪文章(prodnr)的制作过程。在目标金额完成之前,可能会在一次运行或多次运行中生成一篇文章。
如何从该表中获取完整的AMOUNT(completekz = 1)或SUM(AMOUNT)(仅限completekz = 0条目)。
import express from 'express';
import path from 'path';
import webpack from 'webpack';
import webpackMiddleware from 'webpack-dev-middleware';
import webpackHotMiddleware from 'webpack-hot-middleware';
import webpackConfig from '../webpack.config.dev';
let app = express();
const compiler = webpack(webpackConfig);
app.use(webpackMiddleware(compiler, {
hot: true,
publicPath: webpackConfig.output.publicPath,
noInfo: true,
}));
app.use(webpackHotMiddleware(compiler));
app.use('/assets',express.static(__dirname + '/assets'));
app.get('/*', (req, res) => {
res.sendFile(path.join(__dirname,'../index.html'));
})
app.listen(3000, () => console.log('Running port 3000'));
这是我的查询返回所有四行。我似乎无法找到正确的方法。
PRODNR COMPLETEKZ BACOMPLETEKZ AMOUNT
------ ---------- ------------ ----------
... ... ...
16 0 partial 500
16 0 partial 20000
16 0 partial 8000
16 1 complete 40000
17 1 complete 100
18 0 partial 10000
18 0 partial 1500
19 1 complete 35000
... ... ...
答案 0 :(得分:0)
考虑
此
SELECT Q1.prodnr, Sum(IIf(([completekz]=1 And [MaxComp]=1) Or ([completekz]=0 And [MaxComp]=0),[Amount],0)) AS SumAmt
FROM (SELECT aforueck.prodnr, aforueck.completekz, aforueck.bacompletekz, aforueck.amount, DMax("Completekz","aforueck","Prodnr='" & [prodnr] & "'") AS MaxComp
FROM aforueck) AS Q1
GROUP BY prodnr;
或
SELECT aforueck.prodnr, Sum(IIf(([completekz]=1 And [MaxComp]=1) Or ([completekz]=0 And [MaxComp]=0),[Amount],0)) AS SumAmt
FROM (SELECT aforueck.PRODNR, Max(aforueck.COMPLETEKZ) AS MaxComp FROM aforueck GROUP BY aforueck.PRODNR) AS Q1
INNER JOIN aforueck ON Q1.PRODNR = aforueck.PRODNR
GROUP BY aforueck.prodnr;
两者都返回:
+--------+--------+
| prodnr | SumAmt |
+--------+--------+
| 16 | 40000 |
| 17 | 100 |
| 18 | 11500 |
| 19 | 35000 |
+--------+--------+
这符合“完整AMOUNT(completekz = 1)或SUM(AMOUNT)(仅限completekz = 0条目)”的描述。如果这不是所需的输出,请提供一个示例。