I am having trouble with the following view in SQL:
SELECT CAST(AVG(L) AS Decimal(9, 1)) AS LAvg
FROM dbo.HOSurvey_holding
WHERE (L <> 0)
I want one decimal holder but when i have a whole number it doesnt put
a .0 after it? is this possible if so how would i do it? The data i
have in the database averages out to 4 and i would like for it to be
4.0
Any ideas on how i can fix the view so it adds the .0 after whole
numbers.That's a presentation layer issue basically. If you return numbers to your
application, your application should be able to present them in the
appropriate format to the user. VB, Excel, ASP etc all have the appropriate
controls for formatting.
But if you really need to do it in SQL Server, for example because you
create an export to a text file, you can use the STR function:
SELECT STR(AVG(L),10,1)AS LAvg
FROM dbo.HOSurvey_holding
WHERE (L <> 0)
Jacco Schalkwijk
SQL Server MVP
<pkruti@.hotmail.com> wrote in message
news:1113488579.279634.184360@.o13g2000cwo.googlegroups.com...
>I am having trouble with the following view in SQL:
> SELECT CAST(AVG(L) AS Decimal(9, 1)) AS LAvg
> FROM dbo.HOSurvey_holding
> WHERE (L <> 0)
> I want one decimal holder but when i have a whole number it doesnt put
> a .0 after it? is this possible if so how would i do it? The data i
> have in the database averages out to 4 and i would like for it to be
> 4.0
> Any ideas on how i can fix the view so it adds the .0 after whole
> numbers.
>
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment