I´m trying to do the select function of the image below, but the result for "perc_vol_lei" is zero, that is incorrect.
select to_char (tb_esq.datahora, 'yyyy-mm-dd') as data_esq, tb_esq.tick, tb_esq.variacao, tb_esq.quantidade as qtt_26, tb_dir.quantidade as qtt_0,
(tb_esq.quantidade - tb_dir.quantidade) as volume_no_leilao,
((tb_esq.quantidade - tb_dir.quantidade)/tb_esq.quantidade) as perc_vol_lei
from tb_registros as tb_esq
join tb_registros as tb_dir on tb_esq.tick = tb_dir.tick
and to_char(tb_esq.datahora,'yyyy-mm-dd') = to_char(tb_dir.datahora,'yyyy-mm-dd')
where (tb_esq.quantidade - tb_dir.quantidade) > 50000 and tb_esq.refer =26 and tb_dir.refer = 0
AND tb_esq.tick <>'DOLFUTV' and tb_esq.tick <>'IBOV' and tb_esq.tick <>'WDOFUT'and tb_esq.tick <>'DOLFUT'
order by volume_no_leilao desc`
Anyone can help me?