My question is What is the best solution to store Price value in database, keep in mind that I'm going to retrieve entries from that table by this field descending. Decimal, float, double or regular varchar ?
Don't ever use varchar to store monetary data. Use DECIMAL
or NUMERIC
type for this.
DECIMAL/NUMERIC:
Exact precision, operations slight slow. Use this type in data that needs exact number precision. E.g.: Monetary, factors, etc.
FLOAT/DOUBLE:
Inexact precision, operations might be faster than DECIMAL/NUMERIC
. Use this type in data that inexact operations is acceptable. E.g.: Age, scores, etc.
VARCHAR:
Alphanumeric data. E.g.: Name, description, etc.