Pergunta

a customer has a database with all of his products (about 10k). Now he asked me to send him a list with all products which have a price with three or more decimal places (<--- I hope this is the right term. I mean all the numbers after the dot).

I can't think of a query which could to this. Any suggestions?

I am fairly new to MySql that's probably the main problem :-)

Thanks in advance!

Mark

PS: The customer doesn't want to have the numbers rounded - at least not now :-)

Foi útil?

Solução

Mark, try something like this.

SELECT field_name FROM table_name WHERE LENGTH(SUBSTR(column_name,INSTR(column_name,"."))) >3

Outras dicas

This solution also filters decimal places ending with 0, i.e. 123.340 and 123.300 get filtered, as they are essentialy 123.34 and 123.3 respectively.

select 
your_column
from
your_table
where your_column * 100 - floor(your_column * 100) > 0
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top