update view  create sp to replace complex sql