write semantically correct SQL