Added number of sample calcuation directly from MySQL