Having competitive advantage is the fact of having a clearly noticeable advantage over competitors for a long enough period of time. It must be measurable by the clients and resist long enough to reproduction by competitors.
Michael PORTER identifies two major kinds of competitive advantages, costs leadership and differentiation. This translates into the common saying which goes: either you do the same as your competitors at a lower price in which case you should open your shop just opposite theirs and profit from their proximity either you do different things at different prices in which case you'll need to promote yourself and don't need to compare to others.
This is the first of the two competitive advantages. Cost leadership means that you provide a product which is perceived identical to that of your competitors but at a noticeably lower cost.
This generally requires having an organisation focused on process improvement, performance controls and measures, specialised employees, incentives based on productivity, sustained investment in production facilities, design for simple production, strongly structured and optimised organisation, ...
The means to achieving cost reduction (in order to provide lower prices to customers) are very diverse, ranging for example from business process improvement to pressuring providers. In some cases, the research of cost reduction can lead to strategies such as externalisation and offshore production facilities because local production (in occidental countries) can be more expensive.
Differentiation is the strategy to provide a product with sufficient distinctions compared to your competitors so that clients will either not compare or either accept a higher price (if this is the case).
Usually, this strategy requires having polyvalent employees, creativity and intuition friendly environments, motivational incentives, important commercial capacities, leveraging technologies, reputation for quality and technological leadership, strong R&D, ...
This strategy is difficult to achieve because it requires not only finding differentiating characteristics but also they must resist to copying, as otherwise competitors will soon reproduce them thus annihilating invested R&D efforts.