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

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

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

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

    • 蜀后主
      蜀后主

      该行动就行动吧

    • 于松林
      于松林

      • 王镇
        王镇

        话说有钱的马云和捡垃圾的马云都同样说了一句话“天下没有人靠炒股发财”

    • 郝建勋
      郝建勋

      真的真的很爱你

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