Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id F0D5B475C2B for ; Fri, 18 Oct 2002 13:04:49 -0400 (EDT) Received: from wolff.to (unknown [66.93.197.35]) by postgresql.org (Postfix) with SMTP id 40E02475AA1 for ; Fri, 18 Oct 2002 13:04:49 -0400 (EDT) Received: (qmail 26810 invoked by uid 500); 18 Oct 2002 17:13:33 -0000 Date: Fri, 18 Oct 2002 12:13:33 -0500 From: Bruno Wolff III To: Wei Weng Cc: pgsql-sql@postgresql.org Subject: Re: Is there anyway to do this? Message-ID: <20021018171333.GA26785@wolff.to> Mail-Followup-To: Wei Weng , pgsql-sql@postgresql.org References: <1034959557.27181.3.camel@Monet> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1034959557.27181.3.camel@Monet> User-Agent: Mutt/1.3.25i X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200210/216 X-Sequence-Number: 9933 On Fri, Oct 18, 2002 at 12:45:56 -0400, Wei Weng wrote: > I have a table > > Table "Users" > Column | Type | Modifiers > -----------+------------------------+----------- > userid | character varying(40) | not null > username | character varying(64) | > > I want to get all the distinct first character of all usernames. And do > it in a way that is the most portable to MS SQL server. > > Is there anyway? Looking through the documentation on string functions would be helpful. An example solution is: select distinct substring(username from 1 for 1) from users;