If you are buying a second car, your no claims discount may only apply to your first car, but you may still get a lower car insurance quote if you have not made a claim previously and use that car insurance company for your first car.
Some companies offer insurance at lower premiums for specific groups less likely to have an accident, like women, who make less claims. Your premium is almost alway calculated on a risk factor.
Remember any claim made against your insurance company may affect your no claims discount and could lead to higher premiums. You can sometimes protect your no claims with an optional premium. make sure this is transferable to other companies though.