> I need to have a CEIL function in SQLite. This is the way I implemented it: > WITH percentage AS ( > SELECT date > , 100.0 * rank / outOf AS percentage > , CAST(100.0 * rank / outOf AS int) AS castedPercentage > FROM ranking > ) > SELECT date > , (CASE WHEN percentage = castedPercentage > THEN castedPercentage > ELSE castedPercentage + 1 > END) AS percentage > FROM percentage > > Is this a good way, or is there a better way? > Probably you can create your own function
void sqlite3_ceilFunc(sqlite3_context* context, int argc, sqlite3_value** values) { //yourcode } SQliteContext cContext; //any sqlite context sqlite3* pDB; //your DB session sqlite3_create_function(pDB, "CEIL", 1, SQLITE_UTF8, &cContext, &sqlite3_ceilFunc, NULL, NULL);