You are here: Re: "group by" by excluding prefix « MsSQL Server « IT news, forums, messages
Re: "group by" by excluding prefix

Posted by MC on 04/12/06 12:06

Is the length of the string (prefix or sufix) fixed? Can the string be
something like CON_CANA ? Also, it would help if you provided sample
scripts....


MC


"littlebeam" <cyrus.lan@gmail.com> wrote in message
news:1144831660.591396.269760@e56g2000cwe.googlegroups.com...
> Suppose there is a table containing these recodes.
>
> country
> -------
> CON_CHN
> CON_JAP
> JAP
> CON_CHN
>
> When I use the following sql:
> select country, count(*) as num from table group by country
>
> the normal result will be:
> country num
> ---------------
> CON_CHN 2
> CON_JAP 1
> JAP 1
>
> However, my desired result is as follows:
> country num
> -----------------
> CON_CHN 2
> CON_JAP 2
>
> How can I re-write my SQL? Or any other methods to do that?
>

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация