Fix for purchase-log stats sql

Should fix issue #1526