Fix SQL bugs in economy