Received: from news.tht.net (news.hub.org [216.126.91.242]) by postgresql.org (8.11.3/8.11.4) with ESMTP id fBRKuum21681 for ; Thu, 27 Dec 2001 15:56:56 -0500 (EST) (envelope-from news@news.tht.net) Received: (from news@localhost) by news.tht.net (8.11.4/8.11.4) id fBRKSku48560 for pgsql-sql@postgresql.org; Thu, 27 Dec 2001 15:28:46 -0500 (EST) (envelope-from news) From: aannddrree@libero.it (andrea) X-Newsgroups: comp.databases.postgresql.sql Subject: left join and where Date: 27 Dec 2001 12:28:43 -0800 Organization: http://groups.google.com/ Lines: 47 Message-ID: Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Complaints-To: groups-abuse@google.com To: pgsql-sql@postgresql.org X-Archive-Number: 200201/6 X-Sequence-Number: 6097 hello, I'm a beginner and I have a trouble with SQL and Access 97 I try to explain the problem: I have a table colori: ID colore 1 red 2 blu 3 green and a table Vendite ID colore anno quantita 1 red 1 10 2 blu 1 20 3 green 2 30 I want a query that return all "quantita" but only for a year (for example if year =1, I don't extarct green) The result must be: colore anno quantita red 1 10 blu 1 20 green ------------------------------------ I use this SQL code SELECT colori.colore, vendite.anno, sum(vendite.quantita) FROM colori LEFT JOIN vendite ON colori.colore=vendite.colore WHERE vendite.anno=1 OR vendite.anno Is Null GROUP BY colori.colore, vendite.anno But the result is colore anno quantita red 1 10 blu 1 20 How can I get the correct result Thank's for the help Andrea