2016-05-09 13:57 GMT+02:00 Michele Pradella <michele.pradella at selea.com>:

>
> 2016-05-09 13:40 GMT+02:00 Michele Pradella <michele.pradella at selea.com>:
>>
>> 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
>>>>
>>> ?But I want it to be possible for ?everyone? to use the application.
>> People
>> need to implement my function then. Or am I wrong about that?
>>
> Just add CEIL function with (sqlite3_create_function) when you need in
> your code. I do not understand what do you mean with "everyone" anyway if
> your application has the definition of CEIL function everyone using your
> application will have the function


?It is not a real application yet, just thought about it today. But it will
probably be a set of Bash scripts. If those Bash scripts depend on a
modified SQLite, then it would not be easy to use.


-- 
Cecil Westerhof

Reply via email to