Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 text + sum() display data

Author  Topic 

usafelix
Posting Yak Master

165 Posts

Posted - 2015-01-28 : 02:51:51
Anyone can help ?

I want to output this result. how to write this query?

"This is new amount 1000"

select "This is new amount "+@sum(amt) as amount from table


sz1
Aged Yak Warrior

555 Posts

Posted - 2015-01-28 : 05:04:23
-- Are you trying to add @sum variable to field amt?

Declare @num int = 1000
Declare @sum int = 1500
select @num + @sum as amount
from mytable

-- or to sum field amt

select 1000 + sum(amt) as amount
from mytable

We are the creators of our own reality!
Go to Top of Page

viggneshwar
Yak Posting Veteran

86 Posts

Posted - 2015-01-28 : 07:36:47
select "This is new amount "+ cast(sum(amt) as varchar(20)) as amount from table

Regards
Viggneshwar A
Go to Top of Page
   

- Advertisement -