Re: combine column?
Posted in 1999
> select col_a||col_b > from table_name > where... > group by 1 Best Regards, Octav On Fri, Feb 05, 1999 at 10:18:16AM -0600, Yan Zhu wrote: > umm, one more question, what if I need a groupby on the combination of col_a > and col_b? > > something like > select col_a||col_b > from table_name > where... > groupby col_a||col_b > > this of course doesn't work, is there a way? > thanks > yan > > Rekaish Bhardwaj wrote: > > > yes there is an excellent way of doing this. > > > > First of all you need to use the concatenation operator to combine the > > two columns E.g. > > > > select col_a || col_b > > from table_name > > where ...... > > > > this will combine the tow columns together. However the first column > > will retain the trailing spaces. > > To get rid of these spaces so that column b appears right after column a > > then you should use the TRIM > > function. The syntax is something like: > > select TRIM(TRAILING col_a)||col_b from table_name WHERE .... > > > > This only applies to V7.2 I think. If I'm wrong I'm sure somebody will > > correct me. > > If you do not have V7 then I think you can only do this in a 4GL. > > > > Many Regards > > Rekaish > > > > > -----Original Message----- > > > From: Yan Zhu [SMTP:yan.zhu@infinity-insurance.com] > > > Sent: Friday, February 05, 1999 2:12 PM > > > To: informix-list@iiug.org > > > Subject: combine column? > > > > > > > > > hi all: > > > is there anyway to combine text fileds in a select statement? > > > say i have a,b as fields in my table, what would be the sql to > > > output one column whose content is the combination of a and b. If the > > > value in field a is "informix", and the value in b is "iscool", I want > > > my output to be "informixiscool". possible? > > > thanks > > > yan > > > > -- Octav Chiriac Phone: (373) 2 21 20 96 NetInfo S.R.L. Fax: (373) 2 21 36 59 Chisinau (373) 2 24 00 83 Moldova, Republic of mailto:com@netinfo-moldova.com