473,387 Members | 3,801 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Count Issues

Dev

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

Nov 23 '05 #1
5 2028
Dev wrote:
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 ma*******@postgresql.org)

Nov 23 '05 #2
* Dev <de*@umpa-us.com> [2004-10-14 16:54:56 -0400]:
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

Nov 23 '05 #3
How about ...

select count(distinct this) from table

John Sidney-Woollett

Dev wrote:

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 ma*******@postgresql.org)

Nov 23 '05 #4

SELECT COUNT(*) from mytable

-------------------------------------------
Bastianello Luciano
Software Consultant - Apprentice Sorcerer
e-mail: lb**********@virgilio.it
e-mail: lb**********@yahoo.it
ICQ: 209754422 - MSN: ct*****@hotmail.com
-------------------------------------------
---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?

http://archives.postgresql.org

Nov 23 '05 #5
Dev
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:
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

Nov 23 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: brendonlam | last post by:
Hi there, Hoping someone could advise me here pls; I'm creating a C# class that implements a telnet client socket allowing a VB . NET application to communicate with telnet servers. After...
7
by: desi90 | last post by:
Hi, I have a following report created from a table REGION Issue count South C1 3 South C2 1 West C1 4 North C1 2 North C2 5 East C1 1
26
by: G Patel | last post by:
Hi, I'm wondering if anyone knows if the following function will function properly as a set-bit counter on non 2s complement machines (as K&R2 implies). | int bitcount(unsigned x) | { | ...
4
by: Matthew Groch | last post by:
Hi all, I've got a server that handles a relatively high number of concurrent transactions (on the magnitude of 1000's per second). Client applications establish socket connections with the...
2
by: Volkan | last post by:
Hi, I'm trying to compare two XML documents and i'm using XPath queries to select nodes. XPathNavigator's Select method runs fast enough and returns an XPathNodeIterator object. When i try to...
7
sharijl
by: sharijl | last post by:
I have a SQL query which returns the total amount of issues: SELECT issue,Count(issue) as total FROM mytable Group by issue This works but I need the total of the same catagory in three tables...
3
by: cmartin1986 | last post by:
I have written a sql query and I need it to return 0 when it doesn't find any matches to my criteria. I have tried adding iif statements, tried sum, and just Count, all of these methods work fine to...
3
by: Chad Scharf | last post by:
Ok, as silly as it may sound, I have a situation where I am creating a CompositeControl in ASP.NET 2.0, C#. I have the following code in the CreateChildControls() method that build the control's...
1
by: KingofGing | last post by:
Hi All, I'm having a problem writing an SQL statement that I can't quite wrap my head around. First, the background: I have a journal subscription system including 3 tables, tblSubscription,...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.