Here's a query challenge for you. Given:
table foo ( a integer primary key, b integer check (b > 0))
with a limited number of rows (say, <= 10). Values in column "a" are
unique (obviously). Values in column "b" are not.
I want to find a set of values for "a" such that the sum of "b" values
is as close to one-half of the total sum of "b" over all rows. That is,
select 2.0*sum(b) from foo
where a in (...);
would be approximately the same as
select sum(b) from foo;
Likewise,
select 2.0*sum(b) from foo
where a NOT in (...);
would be approximately that value, too.
--
Jeff Boes vox 269.226.9550 ext 24
Database Engineer fax 269.349.9076
Nexcerpt, Inc. http://www.nexcerpt.com ...Nexcerpt... Extend your Expertise