Using Extraction in SQL Server -
i wrote sql query , sample query below:
select value1, value2, value3, ( select cast(amount1 decimal(17,2)) table1 something...) - select cast(amount2 decimal(17,2)) table1 something...) ) 'total purchase' table1
but, getting syntax error @ "-" operator.
i tried use "set" statement below
declare @value1 decimal(17,2), @value2 decimal(17,2), @result decimal(17,2) set value1 = select cast(amount1 decimal(17,2)) table1 something...); set value2 = select cast(amount2 decimal(17,2)) table1 something...); set result = value1 - value2;
but getting syntax error again,
what can use instead of "-" operator.
thnaks advice,,
there lot of things wrong in sql. try this
select value1, value2, value3, (select cast(amount1 decimal(17, 2)) table1 something...) - (select cast(amount2 decimal(17, 2)) table1 something...) 'total purchase' table1
or
declare @value1 decimal(17, 2), @value2 decimal(17, 2), @result decimal(17, 2) set @value1 = (select cast(amount1 decimal(17, 2)) table1 something...) set @value2 = (select cast(amount2 decimal(17, 2)) table1 something...) set @result = @value1 - @value2;
Comments
Post a Comment