sql - Display two decimal values for only one field and no decimals for the rest of the fields -


i have column of float type. need display 2 decimal places when measuredesc = 'amount' others can have whole numbers.

any ideas?

 select   //this works correctly. shows decimal when measuredesc = 'amount'  case when tbl_measures.measuredesc = 'amount'   convert(decimal(10, 2), measurecount)  //here wanted show no decimals when measuredesc not equal 'amount'  when tbl_measures.measuredesc != 'amount' //show no decimals   end measurecount, tbl_measures.name   tbldata 

i tried using floor(measurecount) drops decimals in column.

display of decimal places should handled ui, whatever is. need display values strings work.

assuming ui sql management studio (;-)), should trick:

select measuredesc,     case when measuredesc = 'amount' convert(varchar, convert(decimal(10,2), measurecount))     else convert(varchar, convert(int, measurecount)) end #tbldata 

sql fiddle: http://sqlfiddle.com/#!6/ae995/1


Comments