Re: how do i count() similar items - Mailing list pgsql-general

From jackassplus
Subject Re: how do i count() similar items
Date
Msg-id AANLkTikah-3fB4fpAisWkGMw1AZ_3kuZ-MDRA3Vp6SWh@mail.gmail.com
Whole thread Raw
In response to Re: how do i count() similar items  (Susan Cassidy <scassidy@stbernard.com>)
List 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 by date:

Previous
From: Darren Duncan
Date:
Subject: Re: variable name in plpgsql
Next
From: Edwin Quijada
Date:
Subject: Compiling with MinGW in windows , compile but my server down