문제

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 :-)

도움이 되었습니까?

해결책

Mark, try something like this.

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

다른 팁

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
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top