title: Best method for storing a decimal number with varying number of decimal places
body: <p>We need to store decimal numbers (unit prices) in a database table. The problem is that we need to store and display the same number of decimal places the end-user has given as user input. The maximum number of decimal places is 6. So, for example:</p>
  
  <ul>
  <li>1.00</li>
  <li>9.9999</li>
  <li>0.123456</li>
  </ul>
  
  <p>To start with, for example, DECIMAL(10,6) seems to always store the maximum number of decimals (6).</p>
  
  <p>MONEY stores a varying number of decimals (2-4), but not more than 4 (and has some other issues, why we do not want to use it).</p>
  
  <p>We know that formatting should always be done on the client that uses the data, but it would be nice, if we could query the data so that the query result would have the correct number of decimals automatically.</p>
  
  <p>We are prepared for adding another column that stores the number of decimal places given by the user, and then use that column to format the data for display, but that sounds a bit complex.</p>
  
  <p>If we add another column, is it possible to format the decimal value directly in the query using that column?</p>