Logo

IMSUM_q

Updated 2024-03-13 20:09:40.550000

Syntax

SELECT [westclintech].[wct].[IMSUM_q] (
   <@IMValues_RangeQuery, nvarchar(4000),>)

Description

Use the scalar function IMSUM_q to return the sum of a dataset of complex numbers in x + yi or x + yj text format using dynamic SQL. The sum of 2 complex numbers is computed as:

(a+bi)+(c+di)=(a+c)+(b+d)i

Arguments

@IMValues_RangeQuery

the select statement, as text, used to determine the complex numbers to be used in the IMSUM_q calculation.

Return Type

nvarchar(4000)

Remarks

Use COMPLEX to convert real and imaginary coefficients into a complex number.

For simpler queries consider using the IMSUM function.

Examples

create table #s1

(

    inumber varchar(50)

);

insert into #s1

values

('2+i');

insert into #s1

values

('2-i');

insert into #s1

values

('3+2i');

insert into #s1

values

('3-2i');

select wct.imsum_q('select inumber from #s1');

This produces the following result.

{"columns":[{"field":"column 1","headerClass":"ag-right-aligned-header","cellClass":"ag-right-aligned-cell"}],"rows":[{"column 1":"10"}]}
select wct.IMADD(wct.IMADD('2+i', '2-i'), wct.IMADD('3+2i', '3-2i'));

This produces the following result.

{"columns":[{"field":"column 1","headerClass":"ag-right-aligned-header","cellClass":"ag-right-aligned-cell"}],"rows":[{"column 1":"10"}]}