pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Is there anyway to do this?
3+ messages / 3 participants
[nested] [flat]

* Is there anyway to do this?
@ 2002-10-18 16:45  Wei Weng <wweng@kencast.com>
  0 siblings, 1 reply; 3+ messages in thread

From: Wei Weng @ 2002-10-18 16:45 UTC (permalink / raw)
  To: pgsql-sql

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?

Thanks

-- 
Wei Weng
Network Software Engineer
KenCast Inc.





^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: Is there anyway to do this?
@ 2002-10-18 17:10  Ian Harding <ianh@tpchd.org>
  0 siblings, 0 replies; 3+ messages in thread

From: Ian Harding @ 2002-10-18 17:10 UTC (permalink / raw)
  To: wweng@kencast.com; bruno@wolff.to; +Cc: pgsql-sql

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




^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: Is there anyway to do this?
@ 2002-10-18 17:13  Bruno Wolff III <bruno@wolff.to>
  parent: Wei Weng <wweng@kencast.com>
  0 siblings, 0 replies; 3+ messages in thread

From: Bruno Wolff III @ 2002-10-18 17:13 UTC (permalink / raw)
  To: Wei Weng <wweng@kencast.com>; +Cc: pgsql-sql

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;



^ permalink  raw  reply  [nested|flat] 3+ messages in thread


end of thread, other threads:[~2002-10-18 17:13 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2002-10-18 16:45 Is there anyway to do this? Wei Weng <wweng@kencast.com>
2002-10-18 17:13 ` Bruno Wolff III <bruno@wolff.to>
2002-10-18 17:10 Re: Is there anyway to do this? Ian Harding <ianh@tpchd.org>

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