Received: from fzkmail2.fzk.de (fzkmail2.fzk.de [141.52.27.52]) by postgresql.org (8.11.3/8.11.4) with SMTP id fAD8bNm68170 for ; Tue, 13 Nov 2001 03:37:24 -0500 (EST) (envelope-from ch@rodos.fzk.de) Received: FROM resy5.fzk.de BY fzkmail2.fzk.de ; Tue Nov 13 09:37:20 2001 +0100 Received: by rodos.fzk.de with ESMTP (8.8.6 (PHNE_17135)/8.7.1) id JAA22616; Tue, 13 Nov 2001 09:40:13 +0100 (MET) From: Haller Christoph Message-Id: <200111130835.JAA23920@rodos> Subject: Re: Joins!! To: guru@indvalley.com (Gurudutt) Date: Tue, 13 Nov 2001 9:35:24 MET Cc: pgsql-sql@postgresql.org In-Reply-To: <35769563.20011113111543@indvalley.com>; from "Gurudutt" at Nov 13, 101 7:05 am X-Mailer: Elm [revision: 212.4] X-Archive-Number: 200111/163 X-Sequence-Number: 5547 > > Q 1. Consider the following query, suppose I want the sum of the > tickettabcount and ticketmultabcount, how do I modify my query to get the > same. If I use operator "+" in between these, it's been ignored by the > PgSQL and throws a error!! > > QUERY > ----- > select count(tickettab.tokenid) as tickettabcount, > (select count(tokenid) from ticketmultab > where agentid='danny' and arrivaldate='2001-11-12') as > ticketmultabcount > from tickettab > where tickettab.agentid='danny' and > tickettab.arrivaldate='2001-11-12' > > RESULT > ------- > > > tickettabcount || ticketmultabcount > ------------- ------------------ > 9 2 > Don't use the column name aliasing and it should work: select sum(tickettab.tokenid) + (select sum(tokenid) from ticketmultab where agentid='danny' and arrivaldate='2001-11-12') from tickettab where tickettab.agentid='danny' and tickettab.arrivaldate='2001-11-12' ; > > > Q 2. I join two tables, I get a result set which has values from > both the tables, now if I want to sort the combination of the result > set how do I do that!!, not the individual table result set. > What is so mysterious about your join? To answer your question, it would be very helpful to see the query instead of reading prose. Reagrds, Christoph