Re: Joins!!

From: Haller Christoph <ch(at)rodos(dot)fzk(dot)de>
To: guru(at)indvalley(dot)com (Gurudutt)
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: Joins!!
Date: 2001-11-13 09:35:24
Message-ID: 200111130835.JAA23920@rodos
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-php pgsql-sql

>
> 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

In response to

  • Joins!! at 2001-11-13 05:45:43 from Gurudutt

Responses

Browse pgsql-php by date

  From Date Subject
Next Message Timothy_Maguire 2001-11-13 20:36:59 db connections in session variables
Previous Message Gurudutt 2001-11-13 05:45:43 Joins!!

Browse pgsql-sql by date

  From Date Subject
Next Message Carl van Tast 2001-11-13 10:26:12 Re: Is this a bug?
Previous Message Brian 2001-11-13 09:30:22 INSERT question