The nature of damped Lyman a and sub-damped Lyman a absorbers