On 30 Mar 2012, at 10:22, Richard Huxton wrote:
> On 30/03/12 08:46, Pavel Stehule wrote:
>> 2012/3/30 Richard Huxton:
>>> On 29/03/12 23:28, Pavel Stehule wrote:
select anum from t1 where anum = 4
union all select 100 limit 1;
>>>
>>>
>>> I'm not sure the ordering here is guaran
2012/3/30 Richard Huxton :
> On 30/03/12 08:46, Pavel Stehule wrote:
>>
>> 2012/3/30 Richard Huxton:
>>>
>>> On 29/03/12 23:28, Pavel Stehule wrote:
select anum from t1 where anum = 4
union all select 100 limit 1;
>>>
>>>
>>>
>>> I'm not sure the ordering here is guaranteed by t
On 30/03/12 08:46, Pavel Stehule wrote:
2012/3/30 Richard Huxton:
On 29/03/12 23:28, Pavel Stehule wrote:
select anum from t1 where anum = 4
union all select 100 limit 1;
I'm not sure the ordering here is guaranteed by the standard though, is it?
You could end up with the 4 being discarded.
2012/3/30 Richard Huxton :
> On 29/03/12 23:28, Pavel Stehule wrote:
>>
>> select anum from t1 where anum = 4
>> union all select 100 limit 1;
>
>
> I'm not sure the ordering here is guaranteed by the standard though, is it?
> You could end up with the 4 being discarded.
A order is random for only
On 29/03/12 23:28, Pavel Stehule wrote:
select anum from t1 where anum = 4
union all select 100 limit 1;
I'm not sure the ordering here is guaranteed by the standard though, is
it? You could end up with the 4 being discarded.
--
Richard Huxton
Archonet Ltd
--
Sent via pgsql-general mail
It depends on what exactly it is you're trying to do, and where your
default is supposed to be used. Are you wanting a single number returned?
in that case something like this
SELECT COALESCE((SELECT anum FROM t1 WHERE anum=4 [ LIMIT 1 ]),100)
that would get you back a 4 or 100 in this case. I
On 3/29/12 4:26 PM, Chris Angelico wrote:
On Fri, Mar 30, 2012 at 9:16 AM, David Salisbury wrote:
development=# select coalesce(anum,100) from t1 where anum = 4;
What you have there is rather different from COALESCE, as you're
looking for a case where the row completely doesn't exist. But
Hello
2012/3/30 David Salisbury :
>
> In trying to get an sql stmt to return a default value, I read in the docs..
>
> "The COALESCE function returns the first of its arguments that is not null.
> Null is returned only if all arguments are null. It is often used to
> substitute a default value for
On Fri, Mar 30, 2012 at 9:16 AM, David Salisbury wrote:
> development=# select coalesce(anum,100) from t1 where anum = 4;
What you have there is rather different from COALESCE, as you're
looking for a case where the row completely doesn't exist. But you can
fudge it with an outer join.
Untested
In trying to get an sql stmt to return a default value, I read in the docs..
"The COALESCE function returns the first of its arguments that is not null. Null is returned only if all arguments are null. It is
often used to substitute a default value for null values when data is retrieved for dis
10 matches
Mail list logo