Convert the result value of the sql query

0

I have the query that return me two results where I would like to format it to come in the proper format. How could I do that?

select *, sum(valor) as ValorSoma, count(pedido) as QtdPedido from tb_vendas
where idvendas > 0
and data_venda between '05/10/2015' and '11/04/2016'
and vendedor = ''
group by cliente 
order by QtdPedido desc

ValueSummary type

QtyType integer type

Thank you

    
asked by anonymous 12.04.2016 / 21:04

1 answer

0

If you want the result to be numeric, you need to do a CAST or CONVERT . With you did not specify which DBMS I took the liberty to exemplify in SQL Server:


select 
  *, 
  CAST(sum(valor) AS NUMERIC(10,2)) as ValorSoma, 
  CAST(count(pedido) AS INTEGER) as QtdPedido 
from tb_vendas
where 
  idvendas > 0
  and data_venda between '05/10/2015' and '11/04/2016'
  and vendedor = ''
group by cliente 
order by QtdPedido desc

The above example returns the SumSum field with type Numeric and OrderTime with type Integer .

    
12.04.2016 / 23:25