将 SQL 语句转换为 Qlikview 表达式

Translate the SQL statement in to Qlikview expression

目前我正在尝试编写一个表达式,但我只知道如何在 SQl 语句中查询它

SQL:

1
2
3
4
5
6
SELECT * FROM Orders o
WHERE o.product_name != MBProductName
AND
o.transaction_id IN
(
SELECT m.transaction_id FROM marketBasket m WHERE m.product_name = MBProductName);

我想把结果做成表格形式的图表。

当我选择 MBProductName 时,它?葱写瞬檠?pb>

>谁能帮我翻译一下?提前感?/p>>

>我的脚本?/p>>

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
LOAD  
 Customer_ID,
 Customer_Country,
 Customer_Gender,
 Customer_BirthDate,
 Customer_Age_Group,
 Customer_Type,
 Customer_Age,
 Real_age,
 Continent,
 Country_Name


Orders:
LOAD  
 Customer_ID,
 Employee_ID,
 Street_ID,
 Order_Date,
 Delivery_Date,
 Order_ID AS %%MarketBasket,
 Order_ID,
 Order_Type,
 Product_ID,
 Quantity,
 Total_Retail_Price,
 CostPrice_Per_Unit,
 Discount,
 Profit_per_Product,
 PrfitRange,
 ProfitMarginRange


Products:
LOAD Product_ID,
 Product_Line,
 Product_Category,
 Product_Group,
 Product_Name,
 Supplier_Country,
 Supplier_Name

TmpMarketBasket:
LOAD
%%MarketBasket AS TmpOrderId,
Product_ID AS TmpProductId,
Order_Date AS TmpOrderDate
Resident Orders;

LEFT JOIN
LOAD
Product_ID AS TmpProdcutId,
Product_Name AS TmpProductName,
Product_Line AS TmpProductLine,
Product_Category AS TmpProductCategory,
Product_Group AS TmpProductGroup
Resident Products;

MarketBasket:
LOAD
TmpOrderId                 AS %%MarketBasket,
TmpProductName            AS MBProductName,
TmpProductGroup             AS MBProductGroup
RESIDENT TmpMarketBasket;

DROP TABLE TmpMarketBasket;

我不确de>MarketBasde> 表是如何填充的(也许您可以提供其中一些数据的示例),但是,您可以使用所需字段创建一个直表,然后使用以下表达式作为数量总计:

1
=SUM({$<Product_Name-={$(=GetFieldSelections(MBProductName))}>} Quantity)

它的作用是获取您de>MBProductNde> 上所做的选择,然后在de>Quantde> 字段求和期间将其de>Product_Nde> 中的值中排除。作de>Product_Name = MBProductNde> 总和为零的条目,这些条目将从表中删除。