Hi,
I have a table with no rows for the moment.
table name = mytable
rows = id, id1, qty
id and id1 together is the primary key
when i try tthe following
[CODE=sql]select sum(qty) from mytable where id = 1 and id1 = 1;[/CODE]
this returns NULL
my aim is to subtract a value as this is a subquery in another sql statement.
so if i do
[CODE=sql]select 20 - sum(qty) from mytable where id = 1 and id1 = 1;[/CODE]
it return null, instead of 20.since the table is empty, there are no rows returned for id = 1, id1 = 1;
I tried using sum(case qty when NULL then 0 else qty) but still returns null.
any workarounds to this?
thankyou
I have a table with no rows for the moment.
table name = mytable
rows = id, id1, qty
id and id1 together is the primary key
when i try tthe following
[CODE=sql]select sum(qty) from mytable where id = 1 and id1 = 1;[/CODE]
this returns NULL
my aim is to subtract a value as this is a subquery in another sql statement.
so if i do
[CODE=sql]select 20 - sum(qty) from mytable where id = 1 and id1 = 1;[/CODE]
it return null, instead of 20.since the table is empty, there are no rows returned for id = 1, id1 = 1;
I tried using sum(case qty when NULL then 0 else qty) but still returns null.
any workarounds to this?
thankyou
Comment