Skip site navigation (1) Skip section navigation (2)

Cross-classified table

From: Alexander Pucher <pucher(at)atlas(dot)gis(dot)univie(dot)ac(dot)at>
To: pgsql-novice(at)postgresql(dot)org
Subject: Cross-classified table
Date: 2003-10-20 16:01:20
Message-ID: 3F9406D0.2010404@atlas.gis.univie.ac.at (view raw or flat)
Thread:
Lists: pgsql-novice
Hi,
I'm looking for the correct syntax of getting a cross-classified table 
from my SELECT statement.

Let's pretend I have this table:


origin        sex
----------------
USA        male    
USA        female
China      male
China      male
UK           male
USA        male


and I want as result something like:

               male      female

USA        2            1     
China      2            0
UK           1            0


How can I get this?

Best regards,
alex

  



Responses

pgsql-novice by date

Next:From: Bruno LEVEQUEDate: 2003-10-20 19:53:09
Subject: Re: Cross-classified table
Previous:From: Bruno LEVEQUEDate: 2003-10-20 12:11:56
Subject: Re: [personal] HTML to access a database

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group