Странная работа оконных функций min
, max
в ms sql 2012 при обработке null
–значений. 2 запроса
select max(q1) OVER(PARTITION BY q2 order by q1) from
(
select null as q1, 1 as q2, 0 as q3
union
select 11, 1, 1
union
select null, 1, 1
) a
select max(q1) OVER(PARTITION BY q2) from
(
select null as q1, 1 as q2, 0 as q3
union
select 11, 1, 1
union
select null, 1, 1
) a
Результат первого
- NULL
- NULL
- 11
Второго
- 11
- 11
- 11
Казалось бы причём тут в функциях min max order by...
Microsoft SQL Server 2012 - 11.0.5058.0 (X64)
May 14 2014 18:34:29 Copyright (c) Microsoft Corporation
Enterprise Edition: Core-based
Licensing (64-bit) on Windows NT 6.1 (Build 7601: Service Pack 1)
и
Microsoft SQL Server 2014 - 12.0.2000.8 (X64)
Feb 20 2014 20:04:26
Copyright (c) Microsoft Corporation
Enterprise Edition (64-bit) on
Windows NT 6.3 (Build 9600: )