Click here to Skip to main content
15,881,709 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi Guys I want sum of the row whose datatype is varchar & first character is £ like :

Total
£23.0
£13.0
£2.40

I'm using below query :
SQL
select sum(cast(SUBSTRING(total,2,(LEN(total)))as int)) as Total from tbl_preorder

Any suggestion is really appreciated.
Posted
Updated 27-Aug-13 23:29pm
v3

Please try following query

SQL
select SUM(CAST(SUBSTRING(total, 2,100)AS Decimal)) from tbl_preorder 
 
Share this answer
 
Comments
Mas11 28-Aug-13 5:32am    
Thanks Sandeep for your answer.
TRY LIKE THIS

SELECT SUM(CONVERT(DECIMAL(18,2),SUBSTRING(YOURCOLUMNNAME,2,LEN (YOURCOLUMNNAME)))) FROM
YOURTABLENAME
 
Share this answer
 
Comments
Mas11 28-Aug-13 5:32am    
Thanks It works for me.. 5*..
vangapally Naveen Kumar 28-Aug-13 5:37am    
WELCOME ...........

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900