Saturday, February 25, 2012

CONVERT Problem

I am trying to convert values into a scientific notation format so that 0.7130000 would be displayed as 71.3E -01.
I tried "Select convert(float, MeanValue) as Mean from Values" to no avail.
Any ideas?
Karl
What you're looking for is really a string format -- a floating pointnumber can be displayed by the client however it sees fit (i.e.scientific notation or not). Can you do the formatting on theclient side? There is no easy way I know of to format floats inscientific notation in T-SQL.
|||

There are more than one mean and SQL Server doesnot know the mean you are looking for. I will post some samples but if you send me an email I will send you the papers on Descriptive Statistics. In the master look for three System stored procedures sp_frequencies, sp_median and sp_means run a search for them in the BOL(books online). I would also browse the T-SQL books by Ken Henderson at my local book store. Hope this helps.


SELECT harmonic_mean=
COUNT(*)/SUM(1.0/N_Of_Employees)
FROM dbo.CustomerSummary

harmonic_mean
-------
4.4220114749932304


SELECT geometric_mean=
POWER(10.0000, SUM(LOG10(N_Of_Employees*1.0))/COUNT(*))
FROM dbo.CustomerSummary

geometric_mean
-----
4.8608

|||Adam,
Thanks. I did a search and I think I am getting closer. I just tried:
Dim MyDouble As Double = 5700000000000
lblMsg.Text = MyDouble.ToString("E")
And I got it so I am going to play with it some more.
Karl

No comments:

Post a Comment