sps working query