Fixed version SQL to run on older postgres instances too.