On Friday, 4 January, 2019 04:31, Cecil Westerhof wrote:
>I have the following query:
>SELECT MIN(totalUsed) - 1
>FROM quotes
>WHERE totalUsed <> 'notUsed'
>What I want is that when the SELECT returns a positive value every
>record where totalUsed <> 'notUsed' is lowered with the returned value. Is
>easy to accomplish in programming code, but I was wondering if this could be
>done with a SQL statement.
The English to SQL translator returned the following:
UPDATE quotes
SET totalUsed = totalUsed - (select min(totalUsed) - 1
from quotes
where totalUsed <> 'notUsed')
WHERE ((select min(totalUsed) - 1
from quotes
where totalUsed <> 'notUsed')) > 0
AND totalUsed <> 'notUsed';
---
The fact that there's a Highway to Hell but only a Stairway to Heaven says a
lot about anticipated traffic volume.
_______________________________________________
sqlite-users mailing list
[email protected]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users