为什么 Crosstab 查询返回多行而不是一行?

Why is Crosstab query returning multiple rows instead of one?

我编写了如下查询:

select * from (select *  from crosstab ('select event_item_id, attribute_id, nullif(attribute_value,'''') from event_plan.event_item_attribute_value ',    $$values('size'),('height') ,('floatattr') ,('currencyattr') ,('date_attr') ,('floattwice') $$) as  final_result(event_item_id uuid, size text ,height text ,floatattr text ,currencyattr text ,date_attr text ,floattwice text))    transpose where transpose.event_item_id = '43323dba-d3bf-4f14-a4e0-e55a162864c8';

此查询返回 3 行,而不是我期望的仅返回一行。我在这里做错了什么?

我将 order by event_item_id 添加到现有的交叉表查询中,然后它起作用了。虽然,我仍然不确定它是如何工作的。所以现在我的查询是

select * from (select * from crosstab ('select  event_item_id, attribute_id, attribute_value from event_plan.event_item_attribute_value 
              order by event_item_id', $$values('size'),('height'),('floatattr'),('currencyattr'),('date_attr'),('floattwice') $$) as final_result(event_item_id uuid, size text ,height text ,floatattr text ,currencyattr text ,date_attr text ,floattwice text)) transpose where transpose.event_item_id = '43323dba-d3bf-4f14-a4e0-e55a162864c8';

如果有人能向我解释 order by 子句如何改变查询结果,我将不胜感激。