Re: how to count string occurrence in column

Поиск
Список
Период
Сортировка
От Lee Kindness
Тема Re: how to count string occurrence in column
Дата
Msg-id 15723.18431.500585.267567@kelvin.csl.co.uk
обсуждение исходный текст
Ответ на Re: how to count string occurrence in column  ("Nigel J. Andrews" <nandrews@investsystems.co.uk>)
Ответы Re: how to count string occurrence in column  ("Jules Alberts" <jules.alberts@arbodienst-limburg.nl>)
Re: how to count string occurrence in column  ("Jules Alberts" <jules.alberts@arbodienst-limburg.nl>)
Список pgsql-general
Actually i'm sure the original poster is after something like:

 SELECT count('qwerty qwert qwertyffff fff qq', 'qwerty');
  count
 --------
       2
 (1 row)

But off the top of my head i cannot think of a suitable standard
function...

Lee.

Nigel J. Andrews writes:
 >
 > On Tue, 27 Aug 2002, Ben-Nes Michael wrote:
 > > Hi All
 > >
 > >
 > > How can i count how many time a string 'hello' appear in a column.
 > >
 > > for example.
 > >
 > > select *, count_num_of_string(column, 'hello') from table;
 >
 > SELECT colname, count(1) FROM mytable WHERE colname = 'hello';
 >
 > or case insensitively
 >
 > SELECT colname, count(1) FROM mytable WHERE lower(colname) = 'hello';
 >
 > or get a list of frequencies, most frequent listed first:
 >
 > SELECT colname, count(1) FROM mytable GROUP BY colname ORDER BY 2 DESC;
 >
 >
 > I don't know any good books on SQL but I suggest you see what you can
 > find. Of course there may well be some tutorials available on the web.
 >
 >
 > --
 > Nigel J. Andrews
 > Director
 >
 > ---
 > Logictree Systems Limited
 > Computer Consultants
 >
 >
 > ---------------------------(end of broadcast)---------------------------
 > TIP 4: Don't 'kill -9' the postmaster

В списке pgsql-general по дате отправления:

Предыдущее
От: "Nigel J. Andrews"
Дата:
Сообщение: Re: how to count string occurrence in column
Следующее
От: "Peter Gibbs"
Дата:
Сообщение: Re: Cast Type