Function max E Cast Joins Sql Server 2008 R2

Asked

Viewed 57 times

0

I need to convert an Nvarchar field to Float in a survey, and take the highest value.

this function works

SELECT MAX(valor) 
from [Enops].[dbo].[Tbl_Pulsomedia15_Vazao_Eta_B_Bentes]
Where valor <> 'processando'  and valor <> 'Perda de Sinal'.

but at the time I put max says it is not a sql server function

SELECT Max (cast(valor as nvarchar(200))AS FloatValue) 
from[Enops].[dbo].[Tbl_Pulsomedia15_Vazao_Eta_B_Bentes] 

would have some way of doing this?

1 answer

0

solved

SELECT MAX(cast(replace(convert(varchar,ltrim(rtrim(valor))),',','.') as float)) AS Maximo, 
       MIN(cast(replace(convert(varchar,ltrim(rtrim(valor))),',','.') as float)) AS Mínimo 
From [Enops].[dbo].[Tbl_Pulsomedia15_Vazao_Eta_B_Bentes] 
Where valor <> 'processando'  and valor <> 'Perda de Sinal'

Browser other questions tagged

You are not signed in. Login or sign up in order to post.