manual SQL to plain SQL