In SQL Server anyway, specifying COUNT(*) will be probably more efficient as
it allows the optimizer to choose the best method of returning a row count
rather than forcing it to count a specific column.
Also COUNT(*) will return a count of all rows matching the WHERE condition,
whereas COUNT(c1) will return a count of all rows where c1 IS NOT NULL.
But that's SQL Server - I have no idea about Interbase.
Paul Ritchie
Radio Computing Services.
> -----Original Message-----
> From: Neven MacEwan [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, 14 March 2001 11:39 a.m.
> To: Multiple recipients of list delphi
> Subject: Re: [DUG]: SQL question
>
>
> Alex
>
> You lazy bugger :-) * to me is a no no for efficiency reasons
>
> but you can go
>
> select *, (select count(*) from DetailTable where
> MasterTable.PK = FK) as
> DetailCount
> from MasterTable
>
> HTH
> Neven
>
> ----- Original Message -----
> From: Alex Kouznetsov <[EMAIL PROTECTED]>
> To: Multiple recipients of list delphi <[EMAIL PROTECTED]>
> Sent: Wednesday, 14 March 2001 10:46
> Subject: Re: [DUG]: SQL question
>
>
> > Sum(1) is like Count(*) in this case, they both work if I
> list each column
> > in SELECT clause and then repeat them all in GROUP BY clause.
> >
> > There are too many columns in the master table. I would
> like to use star
> > (*). Less typing and safe for future when columns may be
> added or dropped.
> >
> > Any other ideas ?
> >
> >
> > >
> > > Group by and Sum(1)
> > >
> > > ie
> > > select f1, f2, sum(1) from
> > > table a join table b on a.pk = b.fk
> > > group by f1, f2
> > >
> > > HTH
> > > Neven
> > >
> > > ----- Original Message -----
> > > From: Alex Kouznetsov <[EMAIL PROTECTED]>
> > > To: Multiple recipients of list delphi <[EMAIL PROTECTED]>
> > > Sent: Tuesday, 13 March 2001 14:39
> > > Subject: [DUG]: SQL question
> > >
> > >
> > > > Is there a simple SQL construction to retrieve the
> values of all the
> > > columns
> > > > from a master table and a number of corresponding rows
> in details
> table
> > ?
> > > >
> > > > Eg.
> > > >
> > > > 1,My first transaction, 10/12/2001, 20
> > > > 2,My second transaction, 11/12/2001, 9
> > > >
> > > > Where 20 and 9 are number of details rows for each
> transaction stored
> in
> > > > details table.
> > > >
> > > > I have tried to play with Count(), did not get too far.
> > > >
> > > > Thanks
> > > >
> > > >
> > > >
> > >
> >
> >
> --------------------------------------------------------------
> ------------
> > > -
> > > > New Zealand Delphi Users group - Delphi List -
> [EMAIL PROTECTED]
> > > > Website: http://www.delphi.org.nz
> > > > To UnSub, send email to: [EMAIL PROTECTED]
> > > > with body of "unsubscribe delphi"
> > > >
> > >
> >
> >
> --------------------------------------------------------------
> ------------
> > -
> > > New Zealand Delphi Users group - Delphi List -
> [EMAIL PROTECTED]
> > > Website: http://www.delphi.org.nz
> > > To UnSub, send email to: [EMAIL PROTECTED]
> > > with body of "unsubscribe delphi"
> > >
> >
> >
> --------------------------------------------------------------
> ------------
> -
> > New Zealand Delphi Users group - Delphi List -
> [EMAIL PROTECTED]
> > Website: http://www.delphi.org.nz
> > To UnSub, send email to: [EMAIL PROTECTED]
> > with body of "unsubscribe delphi"
> >
>
> --------------------------------------------------------------
> -------------
> New Zealand Delphi Users group - Delphi List -
> [EMAIL PROTECTED]
> Website: http://www.delphi.org.nz
> To UnSub, send email to: [EMAIL PROTECTED]
> with body of "unsubscribe delphi"
>
---------------------------------------------------------------------------
New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
Website: http://www.delphi.org.nz
To UnSub, send email to: [EMAIL PROTECTED]
with body of "unsubscribe delphi"