oracle sql语句
--SELECT A COUNT(B) FROM TABLE GROUP BY A HAVING COUNT(B)>2 ?//group by 分組;having 分鐘之后過濾
--and (rrbd.paytype = 1?or rrbd.paytype = 2) //or運(yùn)算要在()里!!!!
select (select rrbd.outordercode
from r_reportbilldetails rrbd, r_reportbilldetails_orders rro
where rrbd.sequen = rro.reportbilldetails_seq
and rro.order_seq = od.sequen
and rownum < 2) as outordercode,
od.sequen as ordercode,
si.sellamount as ysprice,
(select sum(rrbd.outmoney)
from r_reportbilldetails rrbd, r_reportbilldetails_orders rro
where rro.reportbilldetails_seq = rrbd.sequen
and rro.order_seq = od.sequen) as outmoney,
0 as localmoney,
0 as cyprice,
'無' as AA,
0 as BB,
od.customername as customername,
(select e.empname from employee e where e.sequen = od.seller) as empname,
od.remark
from orders od, settleinfo si
where si.order_seq = od.sequen
--是否已付款 0:未付款 1:已付款 2已沖銷 3結(jié)算中
--and si.ispay = 1
and exists
(select *
from r_reportbilldetails_orders rro, r_reportbilldetails rrbd
where rro.order_seq = od.sequen
and rro.reportbilldetails_seq = rrbd.sequen
--訂單結(jié)算狀態(tài) 0:已結(jié)算; 1:結(jié)算中;2:未結(jié)算;空是未處理
and rrbd.paytype=0
and exists (select *
from r_reportdetails rrd
where rrd.sequen = rrbd.reportdetails_seq
--and
))
-----------------------------------------------------------------------------------------
select (select rrbd.outordercode
from r_reportbilldetails rrbd, r_reportbilldetails_orders rro
where rrbd.sequen = rro.reportbilldetails_seq
and rro.order_seq = od.sequen
and rownum < 2) as outordercode,
od.sequen as ordercode,
si.sellamount as ysprice,
(select sum(rrbd.outmoney)
from r_reportbilldetails rrbd, r_reportbilldetails_orders rro
where rro.reportbilldetails_seq = rrbd.sequen
and rro.order_seq = od.sequen
--0 解凍 1凍結(jié)
and rrbd.islock = 0) as outmoney,
(select sum(rrbd.outmoney)
from r_reportbilldetails rrbd, r_reportbilldetails_orders rro
where rro.reportbilldetails_seq = rrbd.sequen
and rro.order_seq = od.sequen
--0 解凍 1凍結(jié)
and rrbd.islock = 1) as localmoney,
0 as cyprice,
'無' as AA,
0 as BB,
od.customername as customername,
(select e.empname from employee e where e.sequen = od.seller) as empname,
od.remark
from orders od, settleinfo si
where si.order_seq = od.sequen
--是否已付款 0:未付款 1:已付款 2已沖銷 3結(jié)算中
--and si.ispay = 0 or si.ispay = 3
and exists
(select *
from r_reportbilldetails_orders rro, r_reportbilldetails rrbd
where rro.order_seq = od.sequen
and rro.reportbilldetails_seq = rrbd.sequen
--訂單結(jié)算狀態(tài) 0:已結(jié)算; 1:結(jié)算中;2:未結(jié)算;空是未處理
and (rrbd.paytype = 1
or rrbd.paytype = 2)
and exists (select *
from r_reportdetails rrd
where rrd.sequen = rrbd.reportdetails_seq
--and
))
-------------------------------------------------------------------------------------------
select
rrbd.outordercode,
'無' as ordercode,
0 as ysprice,
0 as outmoney,
0 as localmoney,
rrbd.outmoney as cyprice,
rrbd.entryvaluetype as AA,
rrbd.receivables as BB,
'無' as customername,
'無' as empname,
rrbd.remark
from r_reportbilldetails rrbd,r_reportdetails rrd
where rrd.sequen=rrbd.reportdetails_seq
--and rrd.reportdate
--and rrd.reportuser=
and not exists (select *
from r_reportbilldetails_orders rro
where rro.reportbilldetails_seq = rrbd.sequen)
?
轉(zhuǎn)載于:https://www.cnblogs.com/flord/p/5817008.html
總結(jié)
以上是生活随笔為你收集整理的oracle sql语句的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: presto-docker运行
- 下一篇: cookie的保存时间