Need help in creating one single query which returns list and also does processing when no document found

Thanks @ldoguin, It worked this time.