Is there anyway to do this?

Поиск
Список
Период
Сортировка
Искать

Is there anyway to do this?

От:
Wei Weng <wweng@kencast.com>
Дата:
I have a table 
              Table "Users" Column   |          Type          | Modifiers 
-----------+------------------------+-----------userid    | character varying(40)  | not nullusername  | 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.



Re: Is there anyway to do this?

От:
Bruno Wolff III <bruno@wolff.to>
Дата:
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;

Re: Is there anyway to do this?

От:
"Ian Harding" <ianh@tpchd.org>
Дата:
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  10/18/02 10:13AM >>>
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;

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

http://archives.postgresql.org


FAQ