Query zeroing column when applying order by - Mysql

0

I have a query that when sorting it in ASC it zeroes a column of my table, however if I command in DESC it displays values normally.

This is a query:

SELECT 
'tab_medicamentos'.'id', 'tab_medicamentos'.'classe_terapeutica', 'tab_medicamentos'.'apresentacao', 'tab_medicamentos'.'produto' as 'nome', 'tab_medicamentos'.'pmc_18_perc' as 'preco', 'tab_medicamentos'.'img' as 'imagens', 'tab_medicamentos'.'margem', 'tab_medicamentos'.'margem_desconto', 'tab_medicamentos'.'restrcao_hospitalar' 
FROM 
'tab_medicamentos' 
WHERE 
'classe_terapeutica' LIKE '%M01C0%' ESCAPE '!' 
OR 'classe_terapeutica' LIKE '%L01B0%' ESCAPE '!' 
OR 'classe_terapeutica' LIKE '%N02A0%' ESCAPE '!' 
OR 'classe_terapeutica' LIKE '%N02B0%' ESCAPE '!' 
OR 'classe_terapeutica' LIKE '%N01A2%' ESCAPE '!' 
OR 'classe_terapeutica' LIKE '%N01B1%' ESCAPE '!' 
OR 'classe_terapeutica' LIKE '%M01A1%' ESCAPE '!' 
OR 'classe_terapeutica' LIKE '%M02A0%' ESCAPE '!' 
OR 'classe_terapeutica' LIKE '%R05A0%' ESCAPE '!' 
OR 'classe_terapeutica' LIKE '%A11D4%' ESCAPE '!' 
OR 'classe_terapeutica' LIKE '%A03D0%' ESCAPE '!' 
OR 'classe_terapeutica' LIKE '%M01A3%' ESCAPE '!' 
OR 'classe_terapeutica' LIKE '%B01C1%' ESCAPE '!' 
OR 'classe_terapeutica' LIKE '%M03B0%' ESCAPE '!' 
OR 'classe_terapeutica' LIKE '%N02C9%' ESCAPE '!' 
ORDER BY 'pmc_18_perc' ASC

When I put ORDER BY ASC it zeroes all the values of this column 'pmc_18_perc' , but when I sort in DESC the values normally appear.

What can it be?

    
asked by anonymous 11.05.2018 / 21:08

1 answer

0

Have you tried to sort at a higher level?

Ex:

select * from (SELECT tab_medicamentos , id , tab_medicamentos , classe_terapeutica , tab_medicamentos . apresentacao , tab_medicamentos . produto as nome , tab_medicamentos . pmc_18_perc as preco , tab_medicamentos . img , imagens . tab_medicamentos , margem . tab_medicamentos FROM margem_desconto ONDE tab_medicamentos LIKE '% M01C0%' ESCAPE '!' OR% with% LIKE '% L01B0%' ESCAPE '!' OR% with% LIKE '% N02A0%' ESCAPE '!' OR% with% LIKE '% N02B0%' ESCAPE '!' OR% with% LIKE '% N01A2%' ESCAPE '!' OR% with% LIKE '% N01B1%' ESCAPE '!' OR% with% LIKE '% M01A1%' ESCAPE '!' OR% with% LIKE '% M02A0%' ESCAPE '!' OR% with% LIKE '% R05A0%' ESCAPE '!' OR% with% LIKE '% A11D4%' ESCAPE '!' OR% with% LIKE '% A03D0%' ESCAPE '!' OR% with% LIKE '% M01A3%' ESCAPE '!' OR% with% LIKE '% B01C1%' ESCAPE '!' OR% with% LIKE '% M03B0%' ESCAPE '!' OR% with% LIKE '% N02C9%' ESCAPE '!' ) as tmp

order by tmp.pmc_18_perc desc

    
12.05.2018 / 21:01