Thread: Retreving count of rows returned by a join query

Retreving count of rows returned by a join query

From
"Jasbinder Singh Bali"
Date:
I have a query in which I have joins.

something like

select a.1, b.2 from a, b
where a.3 = b.3;

how can I fetch the number of rows returned by this query.
normal count(*) doesn't work in this context as desired.

Thanks,
~Jas

Re: Retreving count of rows returned by a join query

From
"Phillip Smith"
Date:

Works for me:

 

select count(*) from a, b where a.3 = b.3;

 

-----Original Message-----
From: pgsql-novice-owner@postgresql.org [mailto:pgsql-novice-owner@postgresql.org] On Behalf Of Jasbinder Singh Bali
Sent: Thursday, 31 May 2007 18:32
To: Novice Postgresql-list
Subject: [NOVICE] Retreving count of rows returned by a join query

 

I have a query in which I have joins.

something like

select a.1, b.2 from a, b
where a.3 = b.3;

how can I fetch the number of rows returned by this query.
normal count(*) doesn't work in this context as desired.

Thanks,
~Jas


*******************Confidentiality and Privilege Notice*******************

The material contained in this message is privileged and confidential to the addressee. If you are not the addressee indicated in this message or responsible for delivery of the message to such person, you may not copy or deliver this message to anyone, and you should destroy it and kindly notify the sender by reply email.

Information in this message that does not relate to the official business of Weatherbeeta must be treated as neither given nor endorsed by Weatherbeeta. Weatherbeeta, its employees, contractors or associates shall not be liable for direct, indirect or consequential loss arising from transmission of this message or any attachments

Re: Retreving count of rows returned by a join query

From
"Jasbinder Singh Bali"
Date:
with count(*) i want other  rows as well
something like

select count(*) , a.3 from a, b where a.3 = b.3;

On 5/31/07, Phillip Smith <phillip.smith@weatherbeeta.com.au> wrote:

Works for me:

 

select count(*) from a, b where a.3 = b.3;

 

-----Original Message-----
From: pgsql-novice-owner@postgresql.org [mailto: pgsql-novice-owner@postgresql.org] On Behalf Of Jasbinder Singh Bali
Sent: Thursday, 31 May 2007 18:32
To: Novice Postgresql-list
Subject: [NOVICE] Retreving count of rows returned by a join query

 

I have a query in which I have joins.

something like

select a.1, b.2 from a, b
where a.3 = b.3;

how can I fetch the number of rows returned by this query.
normal count(*) doesn't work in this context as desired.

Thanks,
~Jas


*******************Confidentiality and Privilege Notice*******************

The material contained in this message is privileged and confidential to the addressee. If you are not the addressee indicated in this message or responsible for delivery of the message to such person, you may not copy or deliver this message to anyone, and you should destroy it and kindly notify the sender by reply email.

Information in this message that does not relate to the official business of Weatherbeeta must be treated as neither given nor endorsed by Weatherbeeta. Weatherbeeta, its employees, contractors or associates shall not be liable for direct, indirect or consequential loss arising from transmission of this message or any attachments


Re: Retreving count of rows returned by a join query

From
"Phillip Smith"
Date:

Try a sub-select:

SELECT            a.1,

                                    b.2,

                                    (SELECT count(*) FROM a, b WHERE a.3 = b.3;)

FROM               a, b

WHERE            a.3 = b.3;

 

 

-----Original Message-----
From: pgsql-novice-owner@postgresql.org [mailto:pgsql-novice-owner@postgresql.org] On Behalf Of Jasbinder Singh Bali
Sent: Thursday, 31 May 2007 19:18
To: Phillip Smith
Cc: Novice Postgresql-list
Subject: Re: [NOVICE] Retreving count of rows returned by a join query

 

with count(*) i want other  rows as well
something like

select count(*) , a.3 from a, b where a.3 = b.3;

On 5/31/07, Phillip Smith <phillip.smith@weatherbeeta.com.au> wrote:

Works for me:

 

select count(*) from a, b where a.3 = b.3;

 

-----Original Message-----
From: pgsql-novice-owner@postgresql.org [mailto: pgsql-novice-owner@postgresql.org] On Behalf Of Jasbinder Singh Bali
Sent: Thursday, 31 May 2007 18:32
To: Novice Postgresql-list
Subject: [NOVICE] Retreving count of rows returned by a join query

 

I have a query in which I have joins.

something like

select a.1, b.2 from a, b
where a.3 = b.3;

how can I fetch the number of rows returned by this query.
normal count(*) doesn't work in this context as desired.

Thanks,
~Jas

 

*******************Confidentiality and Privilege Notice*******************

The material contained in this message is privileged and confidential to the addressee. If you are not the addressee indicated in this message or responsible for delivery of the message to such person, you may not copy or deliver this message to anyone, and you should destroy it and kindly notify the sender by reply email.

Information in this message that does not relate to the official business of Weatherbeeta must be treated as neither given nor endorsed by Weatherbeeta. Weatherbeeta, its employees, contractors or associates shall not be liable for direct, indirect or consequential loss arising from transmission of this message or any attachments

 


*******************Confidentiality and Privilege Notice*******************

The material contained in this message is privileged and confidential to the addressee. If you are not the addressee indicated in this message or responsible for delivery of the message to such person, you may not copy or deliver this message to anyone, and you should destroy it and kindly notify the sender by reply email.

Information in this message that does not relate to the official business of Weatherbeeta must be treated as neither given nor endorsed by Weatherbeeta. Weatherbeeta, its employees, contractors or associates shall not be liable for direct, indirect or consequential loss arising from transmission of this message or any attachments

Re: Retreving count of rows returned by a join query

From
Sean Davis
Date:
On Thursday 31 May 2007 05:17, Jasbinder Singh Bali wrote:
> with count(*) i want other  rows as well
> something like
>
> select count(*) , a.3 from a, b where a.3 = b.3;

That would require two queries unless you want to use subqueries:

select count(*) from a,b where a.3=b.3;

select a.3 from a,b where a.3=b.3;

Sean

Re: Retreving count of rows returned by a join query

From
David Gardner
Date:

I know this is an old post that I am responding to, but if you are making these calls from inside of a client application or programming language, often the application or the data structures of the programming language have a count, such as VB’s recordset object has a count() method.

 

---

David Gardner, IT

The Yucaipa Companies

(310) 228-2855


From: pgsql-novice-owner@postgresql.org [mailto:pgsql-novice-owner@postgresql.org] On Behalf Of Jasbinder Singh Bali
Sent: Thursday, May 31, 2007 1:32 AM
To: Novice Postgresql-list
Subject: [NOVICE] Retreving count of rows returned by a join query

 

I have a query in which I have joins.

something like

select a.1, b.2 from a, b
where a.3 = b.3;

how can I fetch the number of rows returned by this query.
normal count(*) doesn't work in this context as desired.

Thanks,
~Jas