oralce中两个不同sql排序问题,求帮忙修改sql
先有两个不同系统,一个是vb做的,一个是java做的,
本来 修改两个sql多加几个栏位排序可以满足要求,但 还有另外一个系统也有相关sql。(不能改动)
另一个系统排序与 vb的排序相同,要求 vb的sql不能改动,改动另外一个sql使得显示结果顺序一致。
vb 中的sql,不能修改此sql。
得到的如下数据:
sequenceno
59
35
31
16
14
48
39
51
66
47
1
另一个系统中的sql
得到的如下数据:
sequenceno
59
39
47
48
35
31
1
51
66
16
14
本来 修改两个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
...全文
相关推荐
sql查询练习问题部分(Oralce版).rar
针对“sql查询练习问题部分(Oralce版).rar”这个压缩包,我们可以推测它包含了一些专为学习Oracle SQL设计的练习题。
Oralce-sql 数据库
这个"Oralce-sql 数据库"的学习资源显然旨在帮助用户理解和掌握Oracle SQL的基本概念、语法和功能。
oralce 维护常用sql语句
- **用途**: 帮助诊断SQL语句的性能问题,如频繁重解析、高磁盘读取等。
Oralce 12.1 SQL Plus
#### 三、SQL Plus 使用场景- **数据库管理和维护**:如创建表、索引,修改表结构等。- **数据查询与分析**:执行复杂查询,对数据进行统计分析。
oralce第00讲-11讲wmv版 oralce基础介绍、安装、基本使用、用户管理、表的管理、表查询.zip
创建、修改和删除表的语法是SQL中的基本操作。此外,还包括对表的索引、分区、约束等高级特性的介绍,这些能提高查询性能和数据完整性。6.


