Updated basic sum query