RE: Select count(*) problem
Posted in 2000
Topics: SQL Development & Query Writing, Platform-Specific Issues
> > Or if using 7.3+ try
> >
> > SELECT FIRST 1 DBINFO('sqlca.sqlerrd2')> >
> > > from table_x
> > > where
> > > column_a=12345
> > > group by column_b
> >
> > HAVING count(*) > 200
>
> That's NOT the coolest answer on this thread so far. :-(
>
> Selecting the number of rows processed for the first record only must
> surely return 1.
Well, I'm using AIX and it has shown me a few funnys but ...
SELECT FIRST 1 DBINFO('sqlca.sqlerrd2')
FROM sysindexes
WHERE tabid < 100
GROUP BY tabid
HAVING count(*) > 2
Definitely doesn't return 1 .
The funny thing is that the hardest part of this SQL was
choosing one that anybody should be able to try :-)
And I have a funny feeling that I'm going to get replies
saying this doesn't work on ver X.XX using OS XXX
___________________________________________________________________________
This email is confidential and intended solely for the use of the
individual to whom it is addressed. Any views or opinions presented are
solely those of the author and do not necessarily represent those of
Sema Group.
If you are not the intended recipient, be advised that you have received this
email in error and that any use, dissemination, forwarding, printing, or
copying of this email is strictly prohibited.
If you have received this email in error please notify the Sema Group
Helpdesk by telephone on +44 (0) 121 627 5600.
___________________________________________________________________________
"COOPER, Joseph" wrote:
> SELECT FIRST 1 DBINFO('sqlca.sqlerrd2')
> FROM sysindexes
> WHERE tabid < 100
> GROUP BY tabid
> HAVING count(*) > 2>
> Definitely doesn't return 1 .
>
DBINFO('sqlca.sqlerrd2') is supposed to return the result of the PREVIOUS sqlstatement (at least on the versions 7.x & 9.2 on HP10.20 that I am working
with).
Try the same SQL statement (DBINFO on sysindexes) above after running this one :
SELECT count(*) from systables;
or after one that returns you more that 1 row. Hopefully - DBINFO had better be
consistent! - the answers you get will actually represent the number of rows of
the previous statement.
Rudy