Re: [SQL] Using || operator to fold multiple columns into one

2009-12-31 Thread Rosser Schwarz
On Tue, Dec 29, 2009 at 4:44 PM, Bryce Nesbitt wrote: > Craig is correct in the OP attempt.   All but one field is intended to be null Ah; my misunderstanding, then. Sorry for the noise. > Duplicate rows, or data in multiple columns, would wreck havoc on the > scheme.  If there is a better way

Re: [SQL] Using || operator to fold multiple columns into one

2009-12-29 Thread Bryce Nesbitt
Craig Ringer wrote: On 24/12/2009 5:04 AM, Rosser Schwarz wrote: On Wed, Dec 23, 2009 at 1:44 AM, Craig Ringer wrote: Your invocation of COALESCE is incorrect -- it is n-ary, but it returns its first non-NULL argument. Yes. That was the point. I think we're assuming the OP wants different th

Re: [SQL] Using || operator to fold multiple columns into one

2009-12-24 Thread Craig Ringer
On 24/12/2009 5:04 AM, Rosser Schwarz wrote: On Wed, Dec 23, 2009 at 1:44 AM, Craig Ringer wrote: SELECT COALESCE( t_number::text, t:string::text, t_date::text, t_boolean::text) AS value; Your invocation of COALESCE is incorrect -- it is n-ary, but it returns its first non-NULL argument.

Re: [SQL] Using || operator to fold multiple columns into one

2009-12-23 Thread Rosser Schwarz
On Wed, Dec 23, 2009 at 1:44 AM, Craig Ringer wrote: > SELECT COALESCE( t_number::text, t:string::text, t_date::text, > t_boolean::text) AS value; Your invocation of COALESCE is incorrect -- it is n-ary, but it returns its first non-NULL argument. Instead, try: SELECT COALESCE(t_number::te

Re: [SQL] Using || operator to fold multiple columns into one

2009-12-23 Thread A. Kretschmer
In response to Bryce Nesbitt : > Dear experts, > > This point is confusing me with the || operator. I've got a table with > "one column per data type", like so: > > # \d context_keyvals; > Table "public.context_keyvals" >Column|Type | Modifiers > --

Re: [SQL] Using || operator to fold multiple columns into one

2009-12-23 Thread Craig Ringer
On 23/12/2009 4:34 PM, Bryce Nesbitt wrote: Dear experts, This point is confusing me with the || operator. I've got a table with "one column per data type", like so: Dare I ask why? What problem are you trying to solve by doing this? # select context_key,keyname,t_number||t_string||t_date||t

[SQL] Using || operator to fold multiple columns into one

2009-12-23 Thread Bryce Nesbitt
Dear experts, This point is confusing me with the || operator. I've got a table with "one column per data type", like so: # \d context_keyvals; Table "public.context_keyvals" Column|Type | Modifiers -+-+---

Re: [SQL] Using & - operator

2003-06-03 Thread Dmitry Tkach
Rado Petrik wrote: Hi, I have table users; id name bin -- 1 xx 9 dec(1) & dec(9) = dec(1) bin(0001) & bin(1001) = bin(0001) This query is bad. SELECT name FROM users WHERE id_user=1 AND (bin & 1) This query return "Warning: PostgreSQL query failed: ERROR: right-

[SQL] Using & - operator

2003-06-03 Thread Rado Petrik
Hi, I have table users; id name bin -- 1 xx 9 dec(1) & dec(9) = dec(1) bin(0001) & bin(1001) = bin(0001) This query is bad. SELECT name FROM users WHERE id_user=1 AND (bin & 1) This query return "Warning: PostgreSQL query failed: ERROR: right- hand side of AND is