>
> 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
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
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
> 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
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
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
>
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