on 07-11-2008 1:18 PM
Hello,
i want to union two tables, first one with 3 fields and second one with 4 fields (diffrent count of fields).
I can add null value at end of first select but it does not work with float values in second table. Value form second table is convert to integer.
For example:
select null v1 from sessions
union
select 0.05 v1 from sessions
result is set of null and 0 value.
As workaround i can type:
select null+0.0 v1 from sessions
union
select 0.05 v1 from sessions
or simple change select's order.
Is any better/proper way to do this? Can I somehow set float field type in first select?
Best regards,
Lukasz.
WIN XP, MAXDB 7.6.03
what about this:
select float(null,5) v1 from sessions
union
select 0.05 v1 from sessions
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Lukasz,
in a UNION statement the first statement defines the structure (number, names and types of fields) of the resultset.
Therefore you have to define a FLOAT field in the first SELECT statement in order to avoid conversion to VARCHAR.
Be aware that NULL and 0.0 are not the same thus NULL+0.0 does not equal NULL.
In fact NULL cannot equal to any number or character value at all.
BTW: you may want to use UNION ALL to avoid the search and removal of duplicates - looks like your datasets won't contain duplicates anyhow...
Regards,
Lars
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
88 | |
23 | |
11 | |
9 | |
8 | |
5 | |
5 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.