Re: [Q] Daves's top 10 SQL question
From: Austin Moseley <\"moseba_at_audv55.aud.alcatel.com'>
Date: 1996/04/10
Message-ID: <4kf0q8$sfo_at_news01.aud.alcatel.com>#1/1
Date: 1996/04/10
Message-ID: <4kf0q8$sfo_at_news01.aud.alcatel.com>#1/1
davidp3_at_soho.ios.com (David Pais) wrote:
>But if PL*SQL used, let say:
>cursor c1 is select my_any_column
>from my_table
>order by sort_rule;
>and then fetch first N record out of active set-well, it will do the job quite
>nicely
A general solution to finding the row(s) which have N copies in the given table across k columns is as follows:
select P, a1, a2,...,ak from
(
select count(*) P ,a1,a2,....,ak from tablename
group by a1,a2,....ak )
where P = N;
Now that we have away to get P and its row value(s), we can then derive any solution based on the value of P.
-Austin Received on Wed Apr 10 1996 - 00:00:00 CEST