Ver Mensaje Individual
  #1 (permalink)  
Antiguo 29/08/2011, 12:40
ingleonidas
 
Fecha de Ingreso: abril-2010
Mensajes: 87
Antigüedad: 14 años, 1 mes
Puntos: 1
Pregunta SUM de un GROUP BY (nvarchar)

Buenas tardes estimados, recurro a uds por la siguiente consulta: Tengo que hacer una suma del siguiente group by:

Código:
select r.campo, COUNT(r.campo) as Cantidad_estado from tabla1 p, tabla2 r 
where  p.Ramo = cast(r.RAMO as CHAR(2)) group by r.campo
he querido hacer la suma asi:

SUM (CONVERT campo TO INT)
o
sum(cast(campo as int))

no funca porque me tira el siguiente error:
Conversion failed when converting the nvarchar value '---' to data type int.

alguna idea??
Graciasss
leo