[Info-Ingres] How to get number of returned rows of another select query?

tianfeichen at gmail.com tianfeichen at gmail.com
Fri May 18 00:36:34 CDT 2007


On May 18, 1:40 pm, tianfeic... at gmail.com wrote:
> To get number of returned rows directly in sql, I usually write sql
> this way:
>   SELECT count(*) as row_count
>   FROM ( SELECT DISTINCT "rt_airline" FROM "route" WHERE "rt_airline"
> IS NOT NULL  )
>
> It works in Access, SQLServer, Oracle, but get syntax error in Ingres.
>
> Is there any way to directly get the result count of sub SELECT query?
> Or is there any special function/keywords to do this?
>
> Thanks.

Fix it by putting "as" behind the sub query. Like this:

  SELECT count(*)
  FROM ( SELECT DISTINCT "rt_airline" FROM "route" WHERE "rt_airline"
IS NOT NULL  )  as row_count

Get it by searching PostgreSQL document...

However this modified sql will not run in Oracle. That is why I don't
like writing sql...

Cheers



More information about the Info-Ingres mailing list