我试图理解为什么GROUP BY函数会根据我引用GROUP-BY字段的方式在snowflake中产生不同的结果.以下是我认为应该产生相同结果的两个查询,但事实并非如此:
使用显式字段别名引用的查询:
select
hash('SHA2_256', CONCAT(field1,field2,field3,field4)) as hash
,field1
,field2
,field3
,field4
,count(*) as count
from <table>
where
<some filters>
group by hash, field1, field2, field3, field4;
使用对字段的位置引用进行查询:
select
hash('SHA2_256', CONCAT(field1,field2,field3,field4)) as hash
,field1
,field2
,field3
,field4
,count(*) as count
from <table>
where
<same filters as above>
group by 1,2,3,4,5;
第一个查询生成的记录要多得多,这表明它可能没有应用第二个查询中应用的分组字段,但基于snowflake docs条记录,我认为它们应该是相同的.这两个有什么不同?