Subject using indices
Author Sergio H. Gonzalez
Hello! I have a table like this:

CREATE TABLE FAC_COM (
[...]
SALDO MONEY /* MONEY = NUMERIC(18,3) DEFAULT 0 */,
[...]
);

CREATE INDEX FAC_COM_IDX4 ON FAC_COM (SALDO);

if I run this query: (of couse, this is just for test!)

select sum(saldo) from fac_com where (saldo=0)

I get this plan:

Plan
PLAN (FAC_COM INDEX (FAC_COM_IDX4))

Adapted Plan
PLAN (FAC_COM INDEX (FAC_COM_IDX4))

But I actually want the opposite:

select sum(saldo) from fac_com where (saldo<>0)
or
select sum(saldo) from fac_com where not (saldo=0)

In both cases I get

Plan
PLAN (FAC_COM NATURAL)

Adapted Plan
PLAN (FAC_COM NATURAL)

How can I do to use the index I've created to sum all the fields which are no
zero?

Thanks!

-s