FROM materialin a, matin b
WHERE b.serial = a.serial) a, matuse b, matback c
WHERE a.mattype = b.mattype (+) AND a.mattype = c.mattype (+) AND
a.matname = b.matname (+) AND a.matname = c.matname (+) AND
a.spec = b.spec (+) AND a.spec = c.spec (+) AND
a.indate = b.outdate (+) AND a.indate = c.backdate (+)
GROUP BY a.mattype, a.matname, a.spec, a.indate
UNION
SELECT b.mattype, b.matname, b.spec, b.outdate, SUM(nvl(a.amount, 0)
- NVL(b.amount, 0) + NVL(c.amount, 0)) AS amount, SUM(nvl(a.matsum,
0) - NVL(b.matsum, 0) + NVL(c.matsum, 0)) AS matsum
FROM (SELECT a.mattype AS mattype, a.matname AS matname,
a.spec AS spec, b.indate AS indate, a.amount AS amount,
a.matsum AS matsum, b.matsource AS matsource
FROM materialin a, matin b
WHERE b.serial = a.serial) a, matuse b, matback c
WHERE a.mattype (+) = b.mattype AND b.mattype = c.mattype (+) AND
a.matname (+) = b.matname AND b.matname = c.matname (+) AND
a.spec (+) = b.spec AND b.spec = c.spec (+) AND
a.indate (+) = b.outdate AND b.outdate = c.backdate (+)
GROUP BY b.mattype, b.matname, b.spec, b.outdate
UNION
SELECT c.mattype, c.matname, c.spec, c.backdate, SUM(nvl(a.amount, 0)
- NVL(b.amount, 0) + NVL(c.amount, 0)) AS amount, SUM(nvl(a.matsum,
0) - NVL(b.matsum, 0) + NVL(c.matsum, 0)) AS matsum
FROM (SELECT a.mattype AS mattype, a.matname AS matname,
a.spec AS spec, b.indate AS indate, a.amount AS amount,
a.matsum AS matsum, b.matsource AS matsource
FROM materialin a, matin b
WHERE b.serial = a.serial) a, matuse b, matback c
本文来自电脑杂谈,转载请注明本文网址:
https://www.pc-fly.com/a/ruanjian/article-30385-28.html
话说有钱的马云和捡垃圾的马云都同样说了一句话“天下没有人靠炒股发财”
真的真的很爱你
该行动就行动吧