postgresql - SQL, select in tables -


hey don't know how it....

its homework: list code , consumers bought cars 'argentina' country.

table sell: 
customer | resell  | veicle    |    date    |  value ---------+---------+-----------+------------+----------  02      | 01      | 03        | 2010-02-05 | 17500.00  04      | 02      | 01        | 2010-01-07 | 28000.00  01      | 03      | 08        | 2010-02-15 | 28000.00  02      | 03      | 02        | 2010-03-12 | 42000.00  03      | 04      | 06        | 2010-02-06 | 11500.00  03      | 02      | 05        | 2010-01-25 | 22100.00  01      | 01      | 04        | 2010-01-21 | 15500.00 

table customer:

 cod    |    name    | lastname --------+------------+------------  01     | jose       | alves  02     | paulo      | cunha  03     | maria      | dpaula  04     | joana      | silveria 

table veicle:

 cod    |manufacturer|     model       | year |  country  |  price --------+------------+-----------------+------+-----------+----------  01     | 01         | gol             | 2000 | brasil    | 25000.00  02     | 01         | golf            | 2005 | argentina | 39000.00  03     | 04         | ford ka         | 1990 | brasil    | 15000.00  04     | 03         | corsa seda      | 1995 | brasil    | 12500.00  05     | 04         | fiesta          | 2003 | argentina | 20000.00  06     | 03         | corsa seda      | 1995 | argentina | 10000.00  07     | 05         | palio           | 2002 | brasil    | 15000.00  08     | 05         | siena           | 2006 | brasil    | 26000.00 

i guess start:

select customer.cod, customer.name  sell, customer  (select cod          veicle          veicle.country = 'argentina') = sell.veicle; 

to select argentine cars... please guide-me answer.

select c.*   customer c exists (     select 1       sell s     join   veicle v on v.cod = s.veicle      s.customer = c.cod     ,    v.country = 'argentina'     ) , not exists (     select 1     ...     ); 

i'll leave rest you, homework. fill in ... exclude customers have bought vehicles not argentina - similar first exists clause. if have understood first, can complete rest.


Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -