pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Ian Harding <ianh@tpchd.org>
To: wweng@kencast.com
To: bruno@wolff.to
Cc: pgsql-sql@postgresql.org
Subject: Re: Is there anyway to do this?
Date: Fri, 18 Oct 2002 10:10:15 -0700
Message-ID: <sdafde4f.055@mail.tpchd.org> (raw)

MSSQL Server does not recognize this syntax, but it does accept 

select distinct substring(username, 1, 1)

Ian A. Harding
Programmer/Analyst II
Tacoma-Pierce County Health Department
(253) 798-3549
iharding@tpchd.org

>>> Bruno Wolff III <bruno@wolff.to> 10/18/02 10:13AM >>>
On Fri, Oct 18, 2002 at 12:45:56 -0400,
  Wei Weng <wweng@kencast.com> 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;

---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?

http://archives.postgresql.org




view thread (3+ messages)  latest in thread

Message-ID: <sdafde4f.055@mail.tpchd.org>
Permalink:  ../sdafde4f.055@mail.tpchd.org/
Also on:    postgresql.org/message-id/sdafde4f.055@mail.tpchd.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: ianh@tpchd.org, wweng@kencast.com, bruno@wolff.to
  Subject: Re: Is there anyway to do this?
  In-Reply-To: <sdafde4f.055@mail.tpchd.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox