Usuário com melhor resposta
Resultado em branco

Pergunta
-
Bom dia a todos,
vejam se podem me ajudar.
SQL
SELECT
MT.SERVICO,
MT.CODTRF,
MT.NOME,
MT.CODUND,
MT.CAMPOLIVREVALOR2 AS 'QTDE',
MT.CAMPOLIVREVALOR1 as 'CONTRATO',
(MT.CAMPOLIVREVALOR2 * ISNULL(MT.CAMPOLIVREVALOR1, MT.VALORUNIT)),
MT.VALORUNIT AS VLR_UNIT,
MT.IDTRF,
MT.IDPRJ
FROM MTRF AS MT
INNER JOIN MPRJ AS MP ON MP.CODCOLIGADA = MT.CODCOLIGADA AND MP.IDPRJ = MT.IDPRJ
WHERE
MT.INDIRETO <> '1'
AND MP.CODPRJ = '02.0041'
AND MT.ATIVA = '1'
group by MT.SERVICO,MT.CODTRF,MT.NOME,MT.CODUND,MT.CAMPOLIVREVALOR2,MT.CAMPOLIVREVALOR1,MT.VALORUNIT,
MT.IDTRF,MT.IDPRJ
ORDER BY MT.CODTRFResultado
Nome Und QTD
RECUPERAÇÃO NULL NULL
SERVIÇOS INICIAIS NULL NULL
Engenharia VB 1.0000resultado esperado
Nome Und QTD
RECUPERAÇÃO
SERVIÇOS INICIAIS
Engenharia VB 1.0000Que ele trata o mesmo resultado porem aonde tiver valor Null, que venha em branco.
obrigado a todos pela ajuda
Respostas
-
-- Se o Campo for inteiro SELECT (cast(MT.CAMPOLIVREVALOR2 as int) * ISNULL(cast(MT.CAMPOLIVREVALOR1 as int), cast(MT.VALORUNIT as int))) FROM MTRF -- Se o Campo tiver casas decimais SELECT (cast(MT.CAMPOLIVREVALOR2 as float) * ISNULL(cast(MT.CAMPOLIVREVALOR1 as float), cast(MT.VALORUNIT as float))) FROM MTRF
Só tome cuidado: Se MT.VALORUNIT for nulo a multiplicação vai retornar nulo.
Abs.
Eduardo Gomes - http://www.h1solucoes.com.br - Twitter: @edugp_sp
- Marcado como Resposta Ronnie Von terça-feira, 17 de abril de 2012 19:15
-
é isto que vc precisa?
SELECT ( cast(MT.CAMPOLIVREVALOR2 as float) * ISNULL(cast(MT.CAMPOLIVREVALOR1 as float), cast(ISNULL(MT.VALORUNIT,0) as float))) FROM MTRF
Eduardo Gomes - http://www.h1solucoes.com.br - Twitter: @edugp_sp
- Marcado como Resposta Ronnie Von terça-feira, 17 de abril de 2012 19:15
Todas as Respostas
-
-
-
-
-
-- Se o Campo for inteiro SELECT (cast(MT.CAMPOLIVREVALOR2 as int) * ISNULL(cast(MT.CAMPOLIVREVALOR1 as int), cast(MT.VALORUNIT as int))) FROM MTRF -- Se o Campo tiver casas decimais SELECT (cast(MT.CAMPOLIVREVALOR2 as float) * ISNULL(cast(MT.CAMPOLIVREVALOR1 as float), cast(MT.VALORUNIT as float))) FROM MTRF
Só tome cuidado: Se MT.VALORUNIT for nulo a multiplicação vai retornar nulo.
Abs.
Eduardo Gomes - http://www.h1solucoes.com.br - Twitter: @edugp_sp
- Marcado como Resposta Ronnie Von terça-feira, 17 de abril de 2012 19:15
-
-
é isto que vc precisa?
SELECT ( cast(MT.CAMPOLIVREVALOR2 as float) * ISNULL(cast(MT.CAMPOLIVREVALOR1 as float), cast(ISNULL(MT.VALORUNIT,0) as float))) FROM MTRF
Eduardo Gomes - http://www.h1solucoes.com.br - Twitter: @edugp_sp
- Marcado como Resposta Ronnie Von terça-feira, 17 de abril de 2012 19:15
-