Search Postgresql Archives

Re: how do i count() similar items

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux