Corrected Document SQL Query