A summary function of a summary function only makes sense if the
grouping changes. In this case, you want COUNT applied to each
V1 x V2 pair, but MAX applied once at each V1 level. But a
SELECT can have only one GROUP BY So this has to be done in
stages. Here is an example. First set up the create table foo as
select sex as v1, age as v2 Next get the counts: create table d3
as select v1, v2, count(*) as pop group by v1, v2; Now use MAX
to identify the highest counts: create table d2 as select * from
d3 group by v1 Of course ties are possible. If you want to apply
an arbitrary tie-breaking rule, another layer is needed: create
table d1 as select * from d2 group by v1 having v2 = min(v2)
order by v1; All of this can be rolled up into one statement, as
Richard demonstrated earlier in this thread. On Tue, 3 May 2005
15:36:03 +0300, Arjen Raateland >Sigurd Hermansen wrote: >>
Unless I am missing something, your program will select the
least common >> combination of v1 with a v2 value. >> In SQL,
the HAVING clause