Using SQL-style functions instead of queries