(Sharecast News) - Goldman Sachs upgraded Royal Bank of Scotland to 'buy' from 'neutral' and lifted the price target by 5% to 345p on Wednesday, citing an attractive valuation and better capital return prospects over the medium term.GS noted that despite making strong progress in working through legacy issues, RBS continues to trade at a meaningful discount to Lloyds, which is unwarranted as RBS's return on tangible equity should match and even exceed Lloyds' over time."In addition, with RBS having a circa 200 basis points higher capital position, we also see better capital return prospects over the medium term (around 40% of market cap by 2022E)," it said.Goldman Sachs retained its 'sell' rating on Lloyds, which it sees as most exposed to the impact of intense competition in the mortgage market.It argued that RBS is comparatively less impacted by tougher mortgage competition as it has a much smaller mortgage book - Lloyds currently has a mortgage book of £289bn, more than double that of RBS's book at £137bn. In addition, it has a much smaller back book and growth ambition means it should likely offset some of the impact of lower rates by volume growth.Finally, it pointed out that having a large non-interest bearing deposit book results in RBS having a comparatively low overall funding costs. "This, in our view, is a key strategic advantage in a more competitive mortgage market," GS said.At 1115 BST, RBS shares were down 0.5% to 245.20p.