oralce中两个不同sql排序问题,求帮忙修改sql

快跑蜗牛哥 快跑蜗牛哥 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
先有两个不同系统,一个是vb做的,一个是java做的,
本来 修改两个sql多加几个栏位排序可以满足要求,但 还有另外一个系统也有相关sql。(不能改动)
另一个系统排序与 vb的排序相同,要求 vb的sql不能改动,改动另外一个sql使得显示结果顺序一致。

vb 中的sql,不能修改此sql。

select C.sequenceno,A.contractid,A.invoiceno,A.fromcountry,A.destination,
A.handbookno,A.importcustom,A.exportcustom,A.forwardername,
A.hktruckno,A.chtruckno,A.containerno,A.tradepat,A.bargainclass,
A.piece,A.packingname,A.grossweight,A.netweight,
A.ciftotal,A.fobtotal,A.shipcost,A.insurancecost,A.repaircost,
A.fxnum,A.palletqtycount,A.palletweightcount,
B.shipno,B.itemno,decode(B.itemdesc,null,' ',B.itemdesc) as itemdesc,
B.quantity,
decode(B.shipmentchr2,null,' ',B.shipmentchr2) as shipmentchr2,
B.itempacking,B.itemnetweight,
B.itemgross,B.originalcountry,B.boxno,B.shipclass,
B.itemgroup,B.autogroupno,B.quantity * B.unitprice as itemprice,
C.customcode,C.chitemname,C.unit,B.unitprice,C.unitlaborprice,
B.curr
,B.ITEMPRICE_MANUAL
from
ct_t_invoice A,(select * from ct_t_shipmenttemp where userid='ADMIN') B,ct_t_contractitem C
where
A.invoiceno=B.invoiceno AND A.contractid=C.contractid AND B.itemno=C.itemno
AND A.invoiceno='45145000049' order by B.itemgroup,B.autogroupno

得到的如下数据:
sequenceno
59
35
31
16
14
48
39
51
66
47
1
另一个系统中的sql

select t.sequenceno,
t.customcode,
t.chitemname,
sum(t.quantity) as quantity,
t.unit,
sum(itemnetweight) as itemnetweight,
t.originalcountry,
t.unitprice,
sum(t.quantity * t.unitprice) itemtotalprice,
t.curr
from (select A.invoiceno,
A.contractid,
B.itemno,
B.quantity,
B.itempacking,
B.itemgroup,
B.autogroupno,
B.itemgross,
B.unitweight * B.quantity as itemnetweight,
decode(trim(B.shipmentchr2),
null,
0,
'',
0,
to_number(B.shipmentchr2)) as shipmentchr2,
decode(sign(B.ITEMPRICE_MANUAL - 0),
1,
B.ITEMPRICE_MANUAL,
B.quantity * B.unitprice) as itemprice,
C.sequenceno,
C.chitemname,
B.unitprice,
B.curr,
C.CUSTOMCODE,
c.unit,
b.originalcountry
from ct_t_invoice A, ct_t_shipment B, ct_t_contractitem C
where A.invoiceno = B.invoiceno
AND A.INVOICENO='45145000049'
and A.contractid = C.contractid
and B.itemno = C.itemno
order by B.itemgroup, B.autogroupno
) t
group by sequenceno,customcode,chitemname,unit,originalcountry,unitprice,curr,itemgroup,autogroupno
order by itemgroup, autogroupno;

得到的如下数据:
sequenceno
59
39
47
48
35
31
1
51
66
16
14
...全文
评论 37
收藏 已收藏
分享
返回顶部