Subject | Re: about substract in sql |
---|---|
Author | Svein Erling Tysvær |
Post date | 2004-09-27T10:33:28Z |
Hi again Novien,
if the fields are integer, then I think your syntax seems OK, i.e.
simply
select (table1.field1 - table2.field2) as newField
from table1
join table2 on ...
where ...
This should work with all numeric fields as well as date and time
(returning a duration). Subtracting from a string doesn't make sense,
but you can use SUBSTRING (unless the fact that I'm occationally using
Paradox, makes me mix up the languages). The result set of such a
query will of course be read only, and records where either of the
fields are NULL will return NULL (unknown is unknown whether the
unknown part is what you had or what you subtract).
Set
if the fields are integer, then I think your syntax seems OK, i.e.
simply
select (table1.field1 - table2.field2) as newField
from table1
join table2 on ...
where ...
This should work with all numeric fields as well as date and time
(returning a duration). Subtracting from a string doesn't make sense,
but you can use SUBSTRING (unless the fact that I'm occationally using
Paradox, makes me mix up the languages). The result set of such a
query will of course be read only, and records where either of the
fields are NULL will return NULL (unknown is unknown whether the
unknown part is what you had or what you subtract).
Set
--- In firebird-support@yahoogroups.com, Novien Effendi wrote:
> the fields types are integer. can u help me svein?
> i want to ask, how if that fields types are string?
>
> thank alot
>
> best regards
> # noven #