Typecasting data in SQL is done with the CAST syntax.
Here's the SQL equivalent of a ruby to_s method. Like many things in SQL, it isn't portable to all databases.
This SQL will fail on MySQL, where you need to use char instead of varchar.
Unsurprisingly, the Sequel code is both more concise and more portable.