This is probably caused by the information being saved to the order or order details tables.
since it happens to some orders and not others, it is probably specific product information coming from the cart. Find out what products they ordering when the problem occurs, then look at the information that gets saved to the cart by the add to cart buttons for those products.
I would guess that there are special characters such as a single or double quote being saved to the cart, or a text value is being saved to the cart, but it is being passed to the orders / order details table as numeric