Posts

Showing posts with the label Sum varchar(20) Column

How to Sum varchar(20) Column

Image
Hello Everyone !!! Hope you are doing well in your programming life.Today I am discussing a short query.This is really so easy but not come in time.I am describing the scenario first,then give solution. Suppose you have a table with having some  data field,you need to sum a column value.in normal case we use : select sum(column_name) from table name where column_name ='condition'  We can use the upper query when the data type is int.If we need to sum varchar data type then the mention query is not working.At that time we need to convert it float type.That time we are able to get the desired result.I am adding a screen short and also the query. The query is look like: Select sum(convert(float,column_name)) from table name where column_name='condition'