In this Microsoft SQL Server 2025 series:
- Dec 01: Microsoft SQL Server 2025 – Introduction and installation
- Dec 02: Microsoft SQL Server 2025 – New T-SQL functions – native JSON data type and some functions
- Dec 03: Microsoft SQL Server 2025 – New T-SQL functions – JSON Index
SQL Server 2025 introduces a new T-SQL function, called PRODUCT(). The function returns the product of all the numeric (and only) values in the expression. NULL values are ignored and DISTINC values can be set.
PRODUCT with NULL
Product() function returns result that NULL values are ignored and product is calculated based on all integers present.
-- NULL
SELECT
PRODUCT(vals)
FROM (VALUES (4), (4), (3), (2), (NULL) ) AS MyTable(vals);
-- result: 4*4*3*2 = 96; NULL IS IGNORED
PRODUCT using DISTINCT
Using DISTINCT will remove duplicates and calculate product only with unique values. Also NULL values are ignored.
-- DISTINCT
SELECT
PRODUCT(DISTINCT vals)
FROM (VALUES (4), (4), (3), (2), (NULL) ) AS MyTable(vals);
-- result: 4*3*2 = 24; NULL IS IGNORED
PRODUCT using OVER Clause
PRODUCT() function also supports the OVER clause to determine the partitioning and ordering of a rowset before the function is applied.
-- OVER CLAUSE with return rate example
SELECT DISTINCT ProductGroup
,PRODUCT(1 + RR_Value) OVER (PARTITION BY ProductGroup ORDER BY ProductGroup) AS CalculatedReturn
FROM (VALUES (0.1626, 'Group1'),
(0.0483, 'Group2'),
(0.2689, 'Group3'),
(0.1944, 'Group1'),
(0.2423, 'Group1'),
(0.3423, 'Group3')
) AS MyTable2(RR_Value, ProductGroup);
A useful T-SQL Function that solves multiple issues regarding multiplications and behaves the same way as SUM(), COUNT() or similar aggregation functions in T-SQL.
Tomorrow we will look into the new T-SQL functions BASE64(); BASE64_ENCODE() and BASE64_DECODE().
As always, the code is available at my Github: https://github.com/tomaztk/SQLServer2025
Happy coding!



[…] Dec 04: Microsoft SQL Server 2025 – New T-SQL functions – Product() […]
LikeLike
[…] Dec 04: Microsoft SQL Server 2025 – New T-SQL functions – Product() […]
LikeLike
[…] Dec 04: Microsoft SQL Server 2025 – New T-SQL functions – Product() […]
LikeLike
[…] Dec 04: Microsoft SQL Server 2025 – New T-SQL functions – Product() […]
LikeLike
[…] Dec 04: Microsoft SQL Server 2025 – New T-SQL functions – Product() […]
LikeLike
[…] Dec 04: Microsoft SQL Server 2025 – New T-SQL functions – Product() […]
LikeLike
[…] Dec 04: Microsoft SQL Server 2025 – New T-SQL functions – Product() […]
LikeLike
[…] Dec 04: Microsoft SQL Server 2025 – New T-SQL functions – Product() […]
LikeLike
[…] Dec 04: Microsoft SQL Server 2025 – New T-SQL functions – Product() […]
LikeLike
[…] Dec 04: Microsoft SQL Server 2025 – New T-SQL functions – Product() […]
LikeLike
[…] Dec 04: Microsoft SQL Server 2025 – New T-SQL functions – Product() […]
LikeLike
[…] Dec 04: Microsoft SQL Server 2025 – New T-SQL functions – Product() […]
LikeLike
[…] Dec 04: Microsoft SQL Server 2025 – New T-SQL functions – Product() […]
LikeLike
[…] Dec 04: Microsoft SQL Server 2025 – New T-SQL functions – Product() […]
LikeLike
[…] Dec 04: Microsoft SQL Server 2025 – New T-SQL functions – Product() […]
LikeLike
[…] Dec 04: Microsoft SQL Server 2025 – New T-SQL functions – Product() […]
LikeLike
[…] Dec 04: Microsoft SQL Server 2025 – New T-SQL functions – Product() […]
LikeLike
[…] Dec 04: Microsoft SQL Server 2025 – New T-SQL functions – Product() […]
LikeLike
[…] Dec 04: Microsoft SQL Server 2025 – New T-SQL functions – Product() […]
LikeLike