Re: how do i count() similar items

Поиск
Список
Период
Сортировка
От jackassplus
Тема Re: how do i count() similar items
Дата
Msg-id AANLkTikah-3fB4fpAisWkGMw1AZ_3kuZ-MDRA3Vp6SWh@mail.gmail.com
обсуждение исходный текст
Ответ на Re: how do i count() similar items  (Susan Cassidy <scassidy@stbernard.com>)
Список pgsql-general
Use a CASE statement?

something like:
select  case WHEN os ~* E'^windows' then 'windows'
  WHEN os ~* E'server' then 'server'
  WHEN os ~* E'nix$' then '*nix'
  else 'other' end
  as osval, count(*) from os_tbl  group by osval order by osval;

The hard part is making sure your regexes cover all the bases, without duplication.

It still sounds like the value should be a reference to a unique value in a small table of operating system entries, then store the value, rather than the string, in the main table.

Susan

I'll give this a shot. looks like it will work well. Regexes, I don't mind, SQL, I'm new at. Much less the pg functions.
thanks to both you and bricklin.

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

Предыдущее
От: Darren Duncan
Дата:
Сообщение: Re: variable name in plpgsql
Следующее
От: Edwin Quijada
Дата:
Сообщение: Compiling with MinGW in windows , compile but my server down