Updated with support for ASC/DESC order in select queries