Sum(Case
When (PP.AccClassid='131' And PP.Acid='300')
Then Ton
Else 0
End
) As 计费顿,
Sum(Case
When PP.AccClassid='131'
Then Fee
Else 0
End
) As 装卸船收入,
Sum(Case
When (PP.AccClassid='11' OR PP.Acid='14')
Then Fee
Else 0
End
) As 杂作业收入
From
(
/* 将相关数据表中用于统计的字段结合成一张表 */
Select
I.ComputerNumber,I.InvoiceDate,
IDe.AccClassid,IDe.ACid1 As Acid,IDe.Money1 As Fee,IDe.Ton1 As Ton,
CC.Caption
From Invoice As I,InvoiceDetail As IDe,Cargo As C,CargoClass As CC
Where
I.ComputerNumber=IDe.InvoiceNumber And
IDe.Cargoid=C.Cargoid and
C.PLevel11=CC.Plevel11
) As PP
Group By Caption
7 个解决方案
#1
不懂
#2
Oracle没接触过,建议无人解答就转版
#3
至今还未听说在SQL Server力可以实现的查询在Oracle实现不了。
以上无非就是视图+case ,据我所知Oracle里这两个特性都很支持。
以上无非就是视图+case ,据我所知Oracle里这两个特性都很支持。
#4
很感谢,只不过听说oracle用的是DECODE
#5
可以,oralce支持的。oracle 9i也有case
#6
支持,可以用DECODE改写。
Select Caption,
Sum(decode(AccClassid||Acid,'131300',Ton,0)) 计费顿,
Sum(decode(AccClassid,'131',Fee,0)) 装卸船收入,
Sum(decode(AccClassid,'11' ,fee,0)+decode(Acid,'14',Fee,0)) 杂作业收入
From
(
/* 将相关数据表中用于统计的字段结合成一张表 */
Select
I.ComputerNumber,I.InvoiceDate,
IDe.AccClassid,IDe.ACid1 As Acid,IDe.Money1 As Fee,IDe.Ton1 As Ton,
CC.Caption
From Invoice As I,InvoiceDetail As IDe,Cargo As C,CargoClass As CC
Where
I.ComputerNumber=IDe.InvoiceNumber And
IDe.Cargoid=C.Cargoid and
C.PLevel11=CC.Plevel11
) Group By Caption,
要分。
Select Caption,
Sum(decode(AccClassid||Acid,'131300',Ton,0)) 计费顿,
Sum(decode(AccClassid,'131',Fee,0)) 装卸船收入,
Sum(decode(AccClassid,'11' ,fee,0)+decode(Acid,'14',Fee,0)) 杂作业收入
From
(
/* 将相关数据表中用于统计的字段结合成一张表 */
Select
I.ComputerNumber,I.InvoiceDate,
IDe.AccClassid,IDe.ACid1 As Acid,IDe.Money1 As Fee,IDe.Ton1 As Ton,
CC.Caption
From Invoice As I,InvoiceDetail As IDe,Cargo As C,CargoClass As CC
Where
I.ComputerNumber=IDe.InvoiceNumber And
IDe.Cargoid=C.Cargoid and
C.PLevel11=CC.Plevel11
) Group By Caption,
要分。
#7
我给,我这多的就剩分了:)
#1
不懂
#2
Oracle没接触过,建议无人解答就转版
#3
至今还未听说在SQL Server力可以实现的查询在Oracle实现不了。
以上无非就是视图+case ,据我所知Oracle里这两个特性都很支持。
以上无非就是视图+case ,据我所知Oracle里这两个特性都很支持。
#4
很感谢,只不过听说oracle用的是DECODE
#5
可以,oralce支持的。oracle 9i也有case
#6
支持,可以用DECODE改写。
Select Caption,
Sum(decode(AccClassid||Acid,'131300',Ton,0)) 计费顿,
Sum(decode(AccClassid,'131',Fee,0)) 装卸船收入,
Sum(decode(AccClassid,'11' ,fee,0)+decode(Acid,'14',Fee,0)) 杂作业收入
From
(
/* 将相关数据表中用于统计的字段结合成一张表 */
Select
I.ComputerNumber,I.InvoiceDate,
IDe.AccClassid,IDe.ACid1 As Acid,IDe.Money1 As Fee,IDe.Ton1 As Ton,
CC.Caption
From Invoice As I,InvoiceDetail As IDe,Cargo As C,CargoClass As CC
Where
I.ComputerNumber=IDe.InvoiceNumber And
IDe.Cargoid=C.Cargoid and
C.PLevel11=CC.Plevel11
) Group By Caption,
要分。
Select Caption,
Sum(decode(AccClassid||Acid,'131300',Ton,0)) 计费顿,
Sum(decode(AccClassid,'131',Fee,0)) 装卸船收入,
Sum(decode(AccClassid,'11' ,fee,0)+decode(Acid,'14',Fee,0)) 杂作业收入
From
(
/* 将相关数据表中用于统计的字段结合成一张表 */
Select
I.ComputerNumber,I.InvoiceDate,
IDe.AccClassid,IDe.ACid1 As Acid,IDe.Money1 As Fee,IDe.Ton1 As Ton,
CC.Caption
From Invoice As I,InvoiceDetail As IDe,Cargo As C,CargoClass As CC
Where
I.ComputerNumber=IDe.InvoiceNumber And
IDe.Cargoid=C.Cargoid and
C.PLevel11=CC.Plevel11
) Group By Caption,
要分。
#7
我给,我这多的就剩分了:)