On 01/05/2015 19:54, Bob M wrote:
Thanks John

I wasn't sure how to enter NULL into an integer field and so col3 has many
zeroes as well as 1, 2, 3, 4, etc.

and so

(a) do your suggestions change at all ?

Replace "IS NOT NULL" with "<> 0" if you're using 0 instead of NULL. The second suggestion I gave should still work if col3 is never negative.

(b) how do you enter NULL into an integer field ?

Just use NULL as the value... will work as long as the column is not defined with a NOT NULL constraint. e.g. "UPDATE mytable SET col3=NULL WHERE col3=0" will replace all zeroes with NULLs in col3.

(c) how do you set up col3 to be indexed ?

CREATE INDEX foo ON mytable(col3 DESC)
    -- (since you'll presumably want descending order of values)

--
John English

Reply via email to