pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Re: COUNT
13+ messages / 9 participants
[nested] [flat]

* Re: COUNT
@ 2000-10-19 18:05  Frank Bax <fbax@execulink.com>
  2 siblings, 0 replies; 13+ messages in thread

From: Frank Bax @ 2000-10-19 18:05 UTC (permalink / raw)
  To: pgsql-sql


Select count(*) from Table

At 04:58 AM 10/20/00 +0000, Craig May wrote:
>Hi,
>
>How do I get a row count, like "Select [COUNT] from Table" ??
>
>Regards,
>Craig May
>
>Enth Dimension
>http://www.enthdimension.com.au
>
>



^ permalink  raw  reply  [nested|flat] 13+ messages in thread

* Re: COUNT
@ 2000-10-19 18:07  Brian C. Doyle <bcdoyle@mindspring.com>
  2 siblings, 1 reply; 13+ messages in thread

From: Brian C. Doyle @ 2000-10-19 18:07 UTC (permalink / raw)
  To: craig.may@s2.enthdimension.com.au; pgsql-sql

Hello,

You will need to do "SELECT count(attribute) FROM  table;" or SELECT 
count(table.attribute);"

At 04:58 AM 10/20/00 +0000, Craig May wrote:
>Hi,
>
>How do I get a row count, like "Select [COUNT] from Table" ??
>
>Regards,
>Craig May
>
>Enth Dimension
>http://www.enthdimension.com.au




^ permalink  raw  reply  [nested|flat] 13+ messages in thread

* Re: COUNT
@ 2000-10-19 18:13  Jie Liang <jliang@ipinc.com>
  parent: Craig May <craig.may@s2.enthdimension.com.au>
  1 sibling, 0 replies; 13+ messages in thread

From: Jie Liang @ 2000-10-19 18:13 UTC (permalink / raw)
  To: craig.may@s2.enthdimension.com.au; +Cc: pgsql-sql

Hi, there,

You want how many rows in your table???

select count(*) from yourtablename;

Craig May wrote:

> Hi,
>
> How do I get a row count, like "Select [COUNT] from Table" ??
>
> Regards,
> Craig May
>
> Enth Dimension
> http://www.enthdimension.com.au

--
Jie LIANG

Internet Products Inc.

10350 Science Center Drive
Suite 100, San Diego, CA 92121
Office:(858)320-4873

jliang@ipinc.com
www.ipinc.com






^ permalink  raw  reply  [nested|flat] 13+ messages in thread

* Re: COUNT
@ 2000-10-19 18:30  Daniel Wickstrom <danw@rtp.ericsson.se>
  parent: Brian C. Doyle <bcdoyle@mindspring.com>
  0 siblings, 0 replies; 13+ messages in thread

From: Daniel Wickstrom @ 2000-10-19 18:30 UTC (permalink / raw)
  To: pgsql-sql

>>>>> "Brian" == Brian C Doyle <bcdoyle@mindspring.com> writes:

    Brian> Hello, You will need to do "SELECT count(attribute) FROM
    Brian> table;" or SELECT count(table.attribute);"


You need to watch this:


acspg=# create table tst (
acspg(# a integer
acspg(# );
CREATE
acspg=# insert into tst values (0);
INSERT 333481 1
acspg=# insert into tst values (null);
INSERT 333482 1
acspg=# insert into tst values (2);
INSERT 333483 1
acspg=# select count(*) from tst;
 count 
-------
     3
(1 row)

acspg=# select count(a) from tst;
 count 
-------
     2
(1 row)

acspg=# select count(1) from tst;
 count 
-------
     3
(1 row)

acspg=# 


If you use the attribut name, null values won't be counted.

-Dan



^ permalink  raw  reply  [nested|flat] 13+ messages in thread

* Re: COUNT
@ 2000-10-19 18:35  bmccoy@chapelperilous.net
  parent: Craig May <craig.may@s2.enthdimension.com.au>
  1 sibling, 0 replies; 13+ messages in thread

From: bmccoy@chapelperilous.net @ 2000-10-19 18:35 UTC (permalink / raw)
  To: Craig May <craig.may@s2.enthdimension.com.au>; +Cc: pgsql-sql

On Fri, 20 Oct 2000, Craig May wrote:

> How do I get a row count, like "Select [COUNT] from Table" ??

SELECT COUNT(*) FROM <table> <where clause>

Brett W. McCoy
                                              http://www.chapelperilous.net
---------------------------------------------------------------------------
Man's reach must exceed his grasp, for why else the heavens?




^ permalink  raw  reply  [nested|flat] 13+ messages in thread

* COUNT
@ 2000-10-20 04:58  Craig May <craig.may@s2.enthdimension.com.au>
  2 siblings, 2 replies; 13+ messages in thread

From: Craig May @ 2000-10-20 04:58 UTC (permalink / raw)
  To: pgsql-sql

Hi,

How do I get a row count, like "Select [COUNT] from Table" ??

Regards,
Craig May

Enth Dimension
http://www.enthdimension.com.au



^ permalink  raw  reply  [nested|flat] 13+ messages in thread

* count(*)
@ 2001-07-03 14:54  Martín Marqués <martin@bugs.unl.edu.ar>
  0 siblings, 1 reply; 13+ messages in thread

From: Martín Marqués @ 2001-07-03 14:54 UTC (permalink / raw)
  To: pgsql-sql

Is it illegal to make a select query with a count(*) in the list of 
expressions to select?

Ex:

select car,tit,count(*) from auto

Saludos.... :-)

-- 
Cualquiera administra un NT.
Ese es el problema, que cualquiera administre.
-----------------------------------------------------------------
Martin Marques                  |        mmarques@unl.edu.ar
Programador, Administrador      |       Centro de Telematica
                       Universidad Nacional
                            del Litoral
-----------------------------------------------------------------



^ permalink  raw  reply  [nested|flat] 13+ messages in thread

* Re: count(*)
@ 2001-07-03 16:17  Martín Marqués <martin@bugs.unl.edu.ar>
  parent: Alex Pilosov <alex@pilosoft.com>
  0 siblings, 2 replies; 13+ messages in thread

From: Martín Marqués @ 2001-07-03 16:17 UTC (permalink / raw)
  To: Alex Pilosov <alex@pilosoft.com>; +Cc: pgsql-sql

On Mié 04 Jul 2001 01:18, Alex Pilosov wrote:
> On Tue, 3 Jul 2001, [iso-8859-1] Martín Marqués wrote:
> > Is it illegal to make a select query with a count(*) in the list of
> > expressions to select?
> >
> > Ex:
> >
> > select car,tit,count(*) from auto
>
> You probably mean:
> select car, tit, (select count(*) from auto) from auto

Well, not the best example.....
How about if I have a WHERE clause? I have to add it twice?

Saludos... :-)

-- 
Cualquiera administra un NT.
Ese es el problema, que cualquiera administre.
-----------------------------------------------------------------
Martin Marques                  |        mmarques@unl.edu.ar
Programador, Administrador      |       Centro de Telematica
                       Universidad Nacional
                            del Litoral
-----------------------------------------------------------------



^ permalink  raw  reply  [nested|flat] 13+ messages in thread

* Re: count(*)
@ 2001-07-03 16:27  Martín Marqués <martin@bugs.unl.edu.ar>
  parent: Alex Pilosov <alex@pilosoft.com>
  0 siblings, 0 replies; 13+ messages in thread

From: Martín Marqués @ 2001-07-03 16:27 UTC (permalink / raw)
  To: Alex Pilosov <alex@pilosoft.com>; +Cc: pgsql-sql

On Mié 04 Jul 2001 01:31, Alex Pilosov wrote:
> On Tue, 3 Jul 2001, [iso-8859-1] Martín Marqués wrote:
> > On Mié 04 Jul 2001 01:18, Alex Pilosov wrote:
> > > On Tue, 3 Jul 2001, [iso-8859-1] Martín Marqués wrote:
> > > > Is it illegal to make a select query with a count(*) in the list of
> > > > expressions to select?
> > > >
> > > > Ex:
> > > >
> > > > select car,tit,count(*) from auto
> > >
> > > You probably mean:
> >
> > Well, not the best example.....
> > How about if I have a WHERE clause? I have to add it twice?
>
> Yes.

I was lmost sure I could add the count(*) in the select, but now that I see 
some old scripts I have, I notic that I was wrong.
Shame on me!

Thanks!

Saludos... :-)

-- 
Cualquiera administra un NT.
Ese es el problema, que cualquiera administre.
-----------------------------------------------------------------
Martin Marques                  |        mmarques@unl.edu.ar
Programador, Administrador      |       Centro de Telematica
                       Universidad Nacional
                            del Litoral
-----------------------------------------------------------------



^ permalink  raw  reply  [nested|flat] 13+ messages in thread

* Re: count(*)
@ 2001-07-03 22:18  Alex Pilosov <alex@pilosoft.com>
  parent: Martín Marqués <martin@bugs.unl.edu.ar>
  0 siblings, 1 reply; 13+ messages in thread

From: Alex Pilosov @ 2001-07-03 22:18 UTC (permalink / raw)
  To: Martín Marqués <martin@bugs.unl.edu.ar>; +Cc: pgsql-sql

On Tue, 3 Jul 2001, [iso-8859-1] Martín Marqués wrote:

> Is it illegal to make a select query with a count(*) in the list of 
> expressions to select?
> 
> Ex:
> 
> select car,tit,count(*) from auto
You probably mean:
select car, tit, (select count(*) from auto) from auto






^ permalink  raw  reply  [nested|flat] 13+ messages in thread

* Re: count(*)
@ 2001-07-03 22:31  Alex Pilosov <alex@pilosoft.com>
  parent: Martín Marqués <martin@bugs.unl.edu.ar>
  1 sibling, 1 reply; 13+ messages in thread

From: Alex Pilosov @ 2001-07-03 22:31 UTC (permalink / raw)
  To: Martín Marqués <martin@bugs.unl.edu.ar>; +Cc: pgsql-sql

On Tue, 3 Jul 2001, [iso-8859-1] Martín Marqués wrote:

> On Mié 04 Jul 2001 01:18, Alex Pilosov wrote:
> > On Tue, 3 Jul 2001, [iso-8859-1] Martín Marqués wrote:
> > > Is it illegal to make a select query with a count(*) in the list of
> > > expressions to select?
> > >
> > > Ex:
> > >
> > > select car,tit,count(*) from auto
> >
> > You probably mean:
> 
> Well, not the best example.....
> How about if I have a WHERE clause? I have to add it twice?
Yes.




^ permalink  raw  reply  [nested|flat] 13+ messages in thread

* Re: count(*)
@ 2001-07-03 23:41  Tom Lane <tgl@sss.pgh.pa.us>
  parent: Martín Marqués <martin@bugs.unl.edu.ar>
  1 sibling, 1 reply; 13+ messages in thread

From: Tom Lane @ 2001-07-03 23:41 UTC (permalink / raw)
  To: Martín Marqués <martin@bugs.unl.edu.ar>; +Cc: Alex Pilosov <alex@pilosoft.com>; pgsql-sql

>> You probably mean:
>> select car, tit, (select count(*) from auto) from auto

I think he probably wants

	select car, tit, count(*) from auto group by car, tit

			regards, tom lane



^ permalink  raw  reply  [nested|flat] 13+ messages in thread

* Re: count(*)
@ 2001-07-04 12:44  Martín Marqués <martin@bugs.unl.edu.ar>
  parent: Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 13+ messages in thread

From: Martín Marqués @ 2001-07-04 12:44 UTC (permalink / raw)
  To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: Alex Pilosov <alex@pilosoft.com>; pgsql-sql

On Mié 04 Jul 2001 02:41, Tom Lane wrote:
> >> You probably mean:
> >> select car, tit, (select count(*) from auto) from auto
>
> I think he probably wants
>
> 	select car, tit, count(*) from auto group by car, tit

Does this mean I would get the same as if I didn't have the count(*), but 
with the additional count(*) column at the end of each row?

Saludos... :-)


-- 
Cualquiera administra un NT.
Ese es el problema, que cualquiera administre.
-----------------------------------------------------------------
Martin Marques                  |        mmarques@unl.edu.ar
Programador, Administrador      |       Centro de Telematica
                       Universidad Nacional
                            del Litoral
-----------------------------------------------------------------



^ permalink  raw  reply  [nested|flat] 13+ messages in thread


end of thread, other threads:[~2001-07-04 12:44 UTC | newest]

Thread overview: 13+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2000-10-19 18:05 ` Frank Bax <fbax@execulink.com>
2000-10-19 18:07 ` Brian C. Doyle <bcdoyle@mindspring.com>
2000-10-19 18:30   ` Daniel Wickstrom <danw@rtp.ericsson.se>
2000-10-20 04:58 ` Craig May <craig.may@s2.enthdimension.com.au>
2000-10-19 18:13   ` Jie Liang <jliang@ipinc.com>
2000-10-19 18:35   ` bmccoy@chapelperilous.net
2001-07-03 14:54 count(*) Martín Marqués <martin@bugs.unl.edu.ar>
2001-07-03 22:18 ` Re: count(*) Alex Pilosov <alex@pilosoft.com>
2001-07-03 16:17   ` Re: count(*) Martín Marqués <martin@bugs.unl.edu.ar>
2001-07-03 22:31     ` Re: count(*) Alex Pilosov <alex@pilosoft.com>
2001-07-03 16:27       ` Re: count(*) Martín Marqués <martin@bugs.unl.edu.ar>
2001-07-03 23:41     ` Re: count(*) Tom Lane <tgl@sss.pgh.pa.us>
2001-07-04 12:44       ` Re: count(*) Martín Marqués <martin@bugs.unl.edu.ar>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox