Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Data Bases > Rdb > Selecting one a...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 1 Topic 180 of 183
Post > Topic >>

Selecting one arbitrarily chosen row from each group

by Ralf <RalfWisser@[EMAIL PROTECTED] > Apr 25, 2007 at 01:13 AM

Hi,

i try to find a query for selecting one arbitrarily chosen row from
each group of rows.

Example:

$ db2 "select * from T"

A           B           C
----------- ----------- -----------
        100           1          10
        100          20           2
        101           3           3

  3 record(s) selected.

The result should be a 'Select A From T group by A' but with one (B,C)-
pair for each group.

So {(100, 1, 10), (101, 3, 3)} and {(100, 20, 2), (101, 3, 3)} would
both be valid results, but not {(100, 1, 2), (101, 3, 3)}.

Is there a way to formulate this in SQL?

Thanks,
Ralf
 




 1 Posts in Topic:
Selecting one arbitrarily chosen row from each group
Ralf <RalfWisser@[EMAI  2007-04-25 01:13:28 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan13V112 Wed Jul 9 1:25:04 CDT 2008.