dbTalk Databases Forums  

Count Issues

comp.databases.postgresql.general comp.databases.postgresql.general


Discuss Count Issues in the comp.databases.postgresql.general forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Dev
 
Posts: n/a

Default Count Issues - 10-14-2004 , 03:54 PM







Hello all,

I am trying to get a total number of rows returned form a query.

SELECT count(this) from table group by this

Currently it is returning x rows with a count of each of the group by.

I need the count of the rows returned!

Any way to do this?



----------

UMPA
Brian C. Doyle
Director, Internet Services
United Merchant Processing Association
<http://www.umpa-us.com>http://www.umpa-us.com
1-800-555-9665 ext 212


Reply With Quote
  #2  
Old   
Andre Maasikas
 
Posts: n/a

Default Re: Count Issues - 10-14-2004 , 04:02 PM






Dev wrote:

Quote:
Hello all,

I am trying to get a total number of rows returned form a query.

SELECT count(this) from table group by this

Currently it is returning x rows with a count of each of the group by.

I need the count of the rows returned!

SELECT COUNT(DISTINCT this) FROM table

Andre

---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddressHere" to majordomo (AT) postgresql (DOT) org)



Reply With Quote
  #3  
Old   
Steven Klassen
 
Posts: n/a

Default Re: Count Issues - 10-14-2004 , 04:03 PM



* Dev <dev (AT) umpa-us (DOT) com> [2004-10-14 16:54:56 -0400]:

Quote:
I am trying to get a total number of rows returned form a query.

SELECT count(this) from table group by this
Remove the 'group by' clause -- you don't need it.

--
Steven Klassen - Lead Programmer
Command Prompt, Inc. - http://www.commandprompt.com/
PostgreSQL Replication & Support Services, (503) 667-4564

---------------------------(end of broadcast)---------------------------
TIP 8: explain analyze is your friend



Reply With Quote
  #4  
Old   
John Sidney-Woollett
 
Posts: n/a

Default Re: Count Issues - 10-14-2004 , 04:09 PM



How about ...

select count(distinct this) from table

John Sidney-Woollett

Dev wrote:
Quote:
Hello all,

I am trying to get a total number of rows returned form a query.

SELECT count(this) from table group by this

Currently it is returning x rows with a count of each of the group by.

I need the count of the rows returned!

Any way to do this?



----------

UMPA
Brian C. Doyle
Director, Internet Services
United Merchant Processing Association
http://www.umpa-us.com>http://www.umpa-us.com
1-800-555-9665 ext 212

---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddressHere" to majordomo (AT) postgresql (DOT) org)



Reply With Quote
  #5  
Old   
Luciano Bastianello
 
Posts: n/a

Default R: Count Issues - 10-14-2004 , 04:28 PM




SELECT COUNT(*) from mytable

-------------------------------------------
Bastianello Luciano
Software Consultant - Apprentice Sorcerer
e-mail: lbastianello (AT) virgilio (DOT) it
e-mail: lbastianello (AT) yahoo (DOT) it
ICQ: 209754422 - MSN: cteniza (AT) hotmail (DOT) com
-------------------------------------------


---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?

http://archives.postgresql.org


Reply With Quote
  #6  
Old   
Dev
 
Posts: n/a

Default Re: Count Issues - 10-15-2004 , 07:47 AM



Thank you all who helped me out on this..
I had tried the distinct but not inside the count.
I was using the group by because this could have multiple returns but after
adding the distinct to inside the count it worked like a charm!!!

Thanks to everyone who helped out on this one!


At 05:01 PM 10/14/2004, Dev wrote:
Quote:
Hello all,

I am trying to get a total number of rows returned form a query.

SELECT count(this) from table group by this

Currently it is returning x rows with a count of each of the group by.

I need the count of the rows returned!

Any way to do this?



----------
Brian C. Doyle
Director, Internet Services
United Merchant Processing Association
http://www.umpa-us.com>http://www.umpa-us.com
1-800-555-9665 ext 212


----------

UMPA
Brian C. Doyle
Director, Internet Services
United Merchant Processing Association
<http://www.umpa-us.com>http://www.umpa-us.com
1-800-555-9665 ext 212



Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.