YAN HONG YE <[email protected]> wrote: > UPDATE bb SET Slevel = > CASE price1>12 WHEN 1 THEN 1 ELSE 0 END + > CASE price1>30 WHEN 1 THEN 1 ELSE 0 END + > CASE price2>20 WHEN 1 THEN 1 ELSE 0 END + > CASE price2>30 WHEN 1 THEN 1 ELSE 0 END + > case... > csse... > ... > CASE price2>80 WHEN 1 THEN 1 ELSE 0 END;
You can simplify this statement to update bb set Slevel= (price1>12) + (price1>30) + (price2>20) + (price2>30) + ... ; Also, if thresholds are regular (as they seem to be), you should be able to calculate the level with a formula, rather than a bunch of cases. For example, if you want to add a level for every 10-point increment in price2, you could do something like min(max((price2 - 11) / 10, 0), 7) -- Igor Tandetnik _______________________________________________ sqlite-users mailing list [email protected] http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

