Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mmczq-0001wr-Ni for pgsql-general@arkaria.postgresql.org; Mon, 15 Nov 2021 14:30:10 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1mmczo-0003qN-UQ for pgsql-general@arkaria.postgresql.org; Mon, 15 Nov 2021 14:30:08 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mmczo-0003q6-Jk for pgsql-general@lists.postgresql.org; Mon, 15 Nov 2021 14:30:08 +0000 Received: from momjian.us ([72.94.173.45]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mmczl-0005dX-CX for pgsql-general@lists.postgresql.org; Mon, 15 Nov 2021 14:30:08 +0000 Received: from bruce by momjian.us with local (Exim 4.92) (envelope-from ) id 1mmczj-0000fJ-76; Mon, 15 Nov 2021 09:30:03 -0500 Date: Mon, 15 Nov 2021 09:30:03 -0500 From: Bruce Momjian To: yarden tamam Cc: pgsql-general@lists.postgresql.org Subject: Re: help with a query Message-ID: <20211115143003.GA22879@momjian.us> References: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Due to time constraints, I do not directly answer general PostgreSQL questions. For assistance, please join the appropriate mailing list and post your question: https://www.postgresql.org/community You can also try the #postgresql IRC channel on irc.freenode.net. See the PostgreSQL FAQ for more information. --------------------------------------------------------------------------- On Sat, Nov 13, 2021 at 11:13:25AM +0200, yarden tamam wrote: > i have data bast that represents basketball teams. and i'm trying to find one > team that has not won yet but has gain that most points during their games from > the other team who have not won yet. > > i wrote a query that is checking if a team has not won at all. but i'm trying > to figure out how to count the points because every team play either at home or > away. > > thank you for you help. > > here is the query the i have wrote so far: > select team.id, nickname,color > from team,points,game > where (team.tid = game.vtid and (vscore - hscore ) < 0)  or (game.htid = > team.tid and (hscore - vscore )< 0 ) > having -- Bruce Momjian https://momjian.us EDB https://enterprisedb.com If only the physical world exists, free will is an illusion.