Re: [GENERAL] how do i count() similar items

2010-09-08 Thread jackassplus
> > 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

Re: [GENERAL] how do i count() similar items

2010-09-08 Thread Susan Cassidy
n -Original Message- From: pgsql-general-ow...@postgresql.org [mailto:pgsql-general-ow...@postgresql.org] On Behalf Of jackassplus Sent: Wednesday, September 08, 2010 12:22 PM To: pgsql-general@postgresql.org Subject: Re: [GENERAL] how do i count() similar items   > To ensure data integr

Re: [GENERAL] how do i count() similar items

2010-09-08 Thread bricklen
On Wed, Sep 8, 2010 at 12:22 PM, jackassplus wrote: > > >> To ensure data integrity, >> you should probably create a fruit_type table with a unique column that >> lists the possible types, and then foreign key the fruit_type column in >> the fruits table to that to ensure nothing funky is entered

Re: [GENERAL] how do i count() similar items

2010-09-08 Thread jackassplus
  > To ensure data integrity, > you should probably create a fruit_type table with a unique column that > lists the possible types, and then foreign key the fruit_type column in > the fruits table to that to ensure nothing funky is entered.  An enum > for type is another possibility. In the real

Re: [GENERAL] how do i count() similar items

2010-09-08 Thread Darren Duncan
jackassplus wrote: lets say I hve the following in the 'fruits' table: Round orange Sunkist orange navel orange strawberry blueberry sunkist orange apple how would I get something like the following: count as c | Fruit type - 4 | orange 2

Re: [GENERAL] how do i count() similar items

2010-09-08 Thread Bill Moran
In response to jackassplus : > lets say I have the following in the 'fruits' table: > > Round orange > Sunkist orange > navel orange > strawberry > blueberry > sunkist orange > apple > > how would I get something like the following: > > count as c | Fruit type >

[GENERAL] how do i count() similar items

2010-09-08 Thread jackassplus
lets say I hve the following in the 'fruits' table: Round orange Sunkist orange navel orange strawberry blueberry sunkist orange apple how would I get something like the following: count as c | Fruit type - 4 | orange 2 | berry 1