Spotfire 的 "min aggregation" 和 "marked by" 是否对应于任何 SQL 语句?
Do Spotfire's "min aggregation" and "marked by" correspond to any SQL statements?
说,我有一个三列两行的 table:
x y my_type
---------------------
4 0 a
2 1 a
1 0 b
这是我要实现的目标:在每个 my_type
、return a 行中具有最小 x
坐标.
以下SQL查询
select min(x), y, my_type
from mydata
group by my_type
结果会给我这个:
x y my_type
---------------------
2 1 a
1 0 b
所以我虽然将 Spotfire 的散点图轴设置为 min(x)
和 y
,并选择 marked by my_type
将仅绘制此 a
类型的点 (2,1 ).但它绘制了 a
类型的点 (4, 0) 和 (2, 1)。
两个问题:
- 如何让它只绘制 (2, 1)?
- 一般来说,Spotfire 的 "min aggregation" 和 "marked by" 是否对应任何 SQL 语句?
我相信你想要下面的查询
select *
from mydata m
where m.x =
(
select min(x) min_x
from mydata
)
DECLARE @TestTable AS TABLE (
X INT,
Y INT,
my_type NVARCHAR(2)
)
INSERT INTO @TestTable
VALUES
(4, 0, 'a')
,(2, 1, 'a')
,(1, 0, 'b')
;WITH MinimumXGroupedByType
AS
(
SELECT
MIN(X) AS min_x
,my_type
FROM @TestTable
GROUP BY my_type
)
SELECT T.* FROM @TestTable AS T
INNER JOIN MinimumXGroupedByType AS M ON [M].[my_type] = T.[my_type] AND [M].[min_x] = T.[X]
Spotfire 不擅长管理您的数据;事实上,它非常糟糕。相反,Spotfire 通常希望您在开始可视化之前弄清楚数据集。上面的其他答案之一可能会在数据库级别帮助您。
假设您使用的是信息 Link,您当然可以根据其中一个答案修改支持所述 link 的 SQL 语句,这可以是解决方案。
简而言之:如果您的数据集有 3 行,则可视化中将显示 3 行,除非其中一些行已被显式过滤掉。
但要回答你的问题:
如何让它只绘制 (2, 1)?
您需要从数据集中删除您不想绘制的其他值,或者使用应用程序中的各种过滤机制之一过滤掉那些特定值(过滤器面板、数据限制表达式等) .).
一般来说,Spotfire的“min aggregation”和“marked by”是否对应于任何SQL语句?
我建议你参考 Marker By documentation from the Spotfire manual:
If you select (Row Number) here, then each row in the data table will be displayed as a separate marker in the visualization, even if several markers have identical values for the X-axis and Y-axis, and therefore are located at the exact same coordinates. These markers will be drawn on top of each other.
You can, however, select to combine markers (known as aggregation) so that each marker shows for example the sum of all rows that have something in common.
Marker By是可视化维度,类似于X轴或Color By。它在任何 SQL 语言中都没有类似的功能或语句,因为它不在同一个驾驶室(或 wheel..city 甚至)。
Min()
聚合应该完全按照您在 SQL 中的预期运行,即,它将 return 包含在列中的最小值。
说,我有一个三列两行的 table:
x y my_type
---------------------
4 0 a
2 1 a
1 0 b
这是我要实现的目标:在每个 my_type
、return a 行中具有最小 x
坐标.
以下SQL查询
select min(x), y, my_type
from mydata
group by my_type
结果会给我这个:
x y my_type
---------------------
2 1 a
1 0 b
所以我虽然将 Spotfire 的散点图轴设置为 min(x)
和 y
,并选择 marked by my_type
将仅绘制此 a
类型的点 (2,1 ).但它绘制了 a
类型的点 (4, 0) 和 (2, 1)。
两个问题:
- 如何让它只绘制 (2, 1)?
- 一般来说,Spotfire 的 "min aggregation" 和 "marked by" 是否对应任何 SQL 语句?
我相信你想要下面的查询
select *
from mydata m
where m.x =
(
select min(x) min_x
from mydata
)
DECLARE @TestTable AS TABLE (
X INT,
Y INT,
my_type NVARCHAR(2)
)
INSERT INTO @TestTable
VALUES
(4, 0, 'a')
,(2, 1, 'a')
,(1, 0, 'b')
;WITH MinimumXGroupedByType
AS
(
SELECT
MIN(X) AS min_x
,my_type
FROM @TestTable
GROUP BY my_type
)
SELECT T.* FROM @TestTable AS T
INNER JOIN MinimumXGroupedByType AS M ON [M].[my_type] = T.[my_type] AND [M].[min_x] = T.[X]
Spotfire 不擅长管理您的数据;事实上,它非常糟糕。相反,Spotfire 通常希望您在开始可视化之前弄清楚数据集。上面的其他答案之一可能会在数据库级别帮助您。
假设您使用的是信息 Link,您当然可以根据其中一个答案修改支持所述 link 的 SQL 语句,这可以是解决方案。
简而言之:如果您的数据集有 3 行,则可视化中将显示 3 行,除非其中一些行已被显式过滤掉。
但要回答你的问题:
如何让它只绘制 (2, 1)?
您需要从数据集中删除您不想绘制的其他值,或者使用应用程序中的各种过滤机制之一过滤掉那些特定值(过滤器面板、数据限制表达式等) .).
一般来说,Spotfire的“min aggregation”和“marked by”是否对应于任何SQL语句?
我建议你参考 Marker By documentation from the Spotfire manual:
If you select (Row Number) here, then each row in the data table will be displayed as a separate marker in the visualization, even if several markers have identical values for the X-axis and Y-axis, and therefore are located at the exact same coordinates. These markers will be drawn on top of each other.
You can, however, select to combine markers (known as aggregation) so that each marker shows for example the sum of all rows that have something in common.
Marker By是可视化维度,类似于X轴或Color By。它在任何 SQL 语言中都没有类似的功能或语句,因为它不在同一个驾驶室(或 wheel..city 甚至)。
Min()
聚合应该完全按照您在 SQL 中的预期运行,即,它将 return 包含在列中的最小值。