我使用IBM DB2 SQL。
这是我当前的查询:
select
EXSHPE as "Shape",
EXDLVY as "Delivery",
Sum(Case When EXSURF = 'Print' Then EXRLTO Else 0 End) As Retail_Print,
Sum(Case When EXSURF = 'Pattern' Then EXRLTO Else 0 End) as Retail_Pattern,
Sum(Case When EXSURF = 'Solid' Then EXRLTO Else 0 End) As Retail_Solid,
Sum(Case When EXSURF = 'UnknownA' Then EXRLTO Else 0 End) as Retail_UnknownA,
Sum(Case When EXSURF = 'UnknownB' Then EXRLTO Else 0 End) As Retail_UnknownB,
Sum(Case When EXSURF = 'UnknownC' Then EXRLTO Else 0 End) as Retail_UnknownC,
Sum(Case When EXSURF = 'Print' Then EXWHLO Else 0 End) As Wholesale_Print,
Sum(Case When EXSURF = 'Pattern' Then EXWHLO Else 0 End) as Wholesale_Pattern,
Sum(Case When EXSURF = 'Solid' Then EXWHLO Else 0 End) As Wholesale_Solid,
Sum(Case When EXSURF = 'UnknownA' Then EXWHLO Else 0 End) as Wholesale_UnknownA,
Sum(Case When EXSURF = 'UnknownB' Then EXWHLO Else 0 End) As Wholesale_UnknownB,
Sum(Case When EXSURF = 'UnknownC' Then EXWHLO Else 0 End) as Wholesale_UnknownC,
Sum(Case When EXSURF = 'Print' Then EXUNTO Else 0 End) As Units_Print,
Sum(Case When EXSURF = 'Pattern' Then EXUNTO Else 0 End) as Units_Pattern,
Sum(Case When EXSURF = 'Solid' Then EXUNTO Else 0 End) As Units_Solid,
Sum(Case When EXSURF = 'UnknownA' Then EXUNTO Else 0 End) as Units_UnknownA,
Sum(Case When EXSURF = 'UnknownB' Then EXUNTO Else 0 End) As Units_UnknownB,
Sum(Case When EXSURF = 'UnknownC' Then EXUNTO Else 0 End) as Units_UnknownC,
Sum(Case When EXSURF = 'Print' Then EXAURA Else 0 End) As Actual_AUR_Print,
Sum(Case When EXSURF = 'Pattern' Then EXAURA Else 0 End) as Actual_AUR_Pattern,
Sum(Case When EXSURF = 'Solid' Then EXAURA Else 0 End) As Actual_AUR_Solid,
Sum(Case When EXSURF = 'UnknownA' Then EXAURA Else 0 End) as Actual_AUR_UnknownA,
Sum(Case When EXSURF = 'UnknownB' Then EXAURA Else 0 End) As Actual_AUR_UnknownB,
Sum(Case When EXSURF = 'UnknownC' Then EXAURA Else 0 End) as Actual_AUR_UnknownC,
Sum(Case When EXSURF = 'Print' Then EXMERA Else 0 End) As Merch_AUR_Print,
Sum(Case When EXSURF = 'Pattern' Then EXMERA Else 0 End) as Merch_AUR_Pattern,
Sum(Case When EXSURF = 'Solid' Then EXMERA Else 0 End) As Merch_AUR_Solid,
Sum(Case When EXSURF = 'UnknownA' Then EXMERA Else 0 End) as Merch_AUR_UnknownA,
Sum(Case When EXSURF = 'UnknownB' Then EXMERA Else 0 End) As Merch_AUR_UnknownB,
Sum(Case When EXSURF = 'UnknownC' Then EXMERA Else 0 End) as Merch_AUR_UnknownC
from EXOWMSPD
Where (EXCO || '/' || EXDIV) = ?
Group By
EXSHPE,
EXDLVY
Order By
EXSHPE DESC,
EXDLVY DESC
数据库看起来像这样:
我需要使用Surface的旋转,但需要动态调整。 问题是,我只知道前三个表面描述。但我需要准备好最多6个。
有没有办法可以动态地转动它以抓住前6个曲面。
示例,
RETAIL_DOLLARS_1 10.00
RETAIL_DOLLARS_2 20.00
RETAIL_DOLLARS_3 50.00
RETAIL_DOLLARS_4 0.00
RETAIL_DOLLARS_5 0.00
RETAIL_DOLLARS_6 0.00
在这个例子中,找到了3个表面的数据,另外3个我希望用0填充。
我正在使用它来制作报告,我将隐藏将SURFACE_DESCRIPTION_X等于“”的列。
有办法做到这一点吗?
由于
答案 0 :(得分:0)
如果您想在各个维度上对数据进行多维数据集,请尝试
GROUP BY CUBE
子句