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

Roy Hann specially at processed.almost.meat
Sun May 20 03:14:54 CDT 2007


<tianfeichen at gmail.com> wrote in message 
news:1179629199.375579.195150 at u30g2000hsc.googlegroups.com...
> On May 20, 11:35 am, tianfeic... at gmail.com wrote:
> Yeah! I finally found the solution:
>
>  select count (distinct (r1.rt_airline))
>  from route r1
>  where r1.rt_airline in
> (select distinct r2.rt_airline
> from route r2
> where r2.rt_airline = r1.rt_airline)

If that gives you what you want, what does this give you?

    select count(distinct rt_airline) from route;

> It gives me exactly what I want. Using sub query in where clause is
> fairly common way. Do you think it will work with previous version of
> Ingres?

Yes.

> BTW, I used and relied too much on ORM and now should reinforce my SQL
> skills.

That might be a very good idea.  SQL is an almost trivial language to learn. 
Even the toughest parts (aggregation and grouping) shouldn't take more than 
an hour or so of concentration to fully master.  Once you can write 
effective SQL you can write applications that send the queries to the data 
instead of bringing the data to the application to be queried.  You 
mentioned in an earlier post that you were concerned about efficiency. 
Sending a few dozen bytes of SQL to the DBMS server is always going to be 
way more efficient than sending millions of rows of data to the application.

Roy 




More information about the Info-Ingres mailing list