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.
Author |
Topic |
vignesht50
Yak Posting Veteran
82 Posts |
Posted - 2014-04-11 : 05:20:43
|
Hi,I have this query where I do certain conversions and on top of this how can I sum the column values.'$ '+ Replace(CONVERT(varchar,CAST(Total_Amount AS money),1) ,'.00','') as Total_Amount,'$ '+ Replace(CONVERT(varchar,CAST(Monthly_Amount As money),1),'.00','') as Monthly_Amount, |
|
Robowski
Posting Yak Master
101 Posts |
Posted - 2014-04-11 : 07:52:32
|
USE tempdb;GOIF OBJECT_ID ('#TempTable', 'U') IS NOT NULL DROP TABLE #TempTable;GOCREATE TABLE #TempTable (ColumnOne int not null, ColumnTwo int not null)INSERT #TempTableVALUES (2,2);INSERT #TempTableVALUES (2,2);GO;WITH CTE_SumAS ( SELECT CAST(ColumnOne as MONEY) as TotalAmount , CAST(ColumnTwo as MONEY) as MonthlyAmount FROM #TempTable )SELECT '$' + CAST(SUM(TotalAmount) as varchar) as TotalAmount , '$' + CAST(SUM(MonthlyAmount) as varchar) as MonthlyAmountFROM CTE_Sum |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2014-04-11 : 08:05:29
|
This is the formation issue that should be done in a front end application unless you export the result to a text file MadhivananFailing to plan is Planning to fail |
|
|
|
|
|
|
|