Sorry to bother you with Postgress problem in ANSI-SQL
forum, but I didn't find any good postgress forum, so i hope someone here is able to help me.
I have problem with with NULLs.
My problem is as follows:
I have for example this table:
id | timestamps
---------------
1 | 9999343
---------------
2 |
---------------
3 | 9993434
--------------
4 |
where blank spaces are NULLs, and timestamps are unix timestamps.
Now I want to select value from my_table so that when the resulting row contains something, it will return 1 and when it is NULL the select will return 0
So I want this result:
1
_
0
_
1
_
0
I have tried almost everything but i CANNOT substitute NULLs
with 0 (or anything else, except NULL). It colud be done with the help of UNIONs but i am not allowed to use them, because after using UNION i cannot order the result.
Is postgress able to do any operation with NULLs?
for example: select col1 + 1 from table;
if the number in the col1 is a number, postgres will add 1 to that number. But if it is NULL it will return NULL, even if I explicitely cast NULL to type integer.
I have tried to apply many functions to critical column, but every function which i tried returned NULL instead anything else.
forum, but I didn't find any good postgress forum, so i hope someone here is able to help me.
I have problem with with NULLs.
My problem is as follows:
I have for example this table:
id | timestamps
---------------
1 | 9999343
---------------
2 |
---------------
3 | 9993434
--------------
4 |
where blank spaces are NULLs, and timestamps are unix timestamps.
Now I want to select value from my_table so that when the resulting row contains something, it will return 1 and when it is NULL the select will return 0
So I want this result:
1
_
0
_
1
_
0
I have tried almost everything but i CANNOT substitute NULLs
with 0 (or anything else, except NULL). It colud be done with the help of UNIONs but i am not allowed to use them, because after using UNION i cannot order the result.
Is postgress able to do any operation with NULLs?
for example: select col1 + 1 from table;
if the number in the col1 is a number, postgres will add 1 to that number. But if it is NULL it will return NULL, even if I explicitely cast NULL to type integer.
I have tried to apply many functions to critical column, but every function which i tried returned NULL instead anything else.