Fixed SQL Query for inventory.