sql查询员工入职多少天_sql 查询四舍五入_sql怎么四舍五入(29)

电脑杂谈  发布时间:2017-02-03 23:10:24  来源:网络整理

WHERE a.mattype (+) = c.mattype AND b.mattype (+) = c.mattype AND

a.matname (+) = c.matname AND c.matname = b.matname (+) AND

c.spec = a.spec (+) AND c.spec = b.spec (+) AND

c.backdate = b.outdate (+) AND c.backdate = a.indate (+)

GROUP BY c.mattype, c.matname, c.spec, c.backdate) a,

(SELECT a.mattype, a.matname, a.spec, a.indate, 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 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 AS indate,

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


本文来自电脑杂谈,转载请注明本文网址:
https://www.pc-fly.com/a/ruanjian/article-30385-29.html

相关阅读
    发表评论  请自觉遵守互联网相关的政策法规,严禁发布、暴力、反动的言论

    热点图片
    拼命载入中...