Обсуждение: count(*)
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
-----------------------------------------------------------------
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
-----------------------------------------------------------------
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
-----------------------------------------------------------------
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.
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
>> 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
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
-----------------------------------------------------------------