Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 12890

Using Cast With Case

$
0
0

I want my answer to be in decimal format, showing 4 decimal places.  I attempted this, and it shows me the error of Incorrect syntax near 'CAST', epected 'As'

Select
Round(Avg(Cast(case when isfarm = 'Yes' And morethan10 = 'Yes' then buildyear Else Null End) As Float), 4)
From insurance



Viewing all articles
Browse latest Browse all 12890

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>