dbTalk Databases Forums  

Selecting one arbitrarily chosen row from each group

comp.databases.rdb comp.databases.rdb


Discuss Selecting one arbitrarily chosen row from each group in the comp.databases.rdb forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Ralf
 
Posts: n/a

Default Selecting one arbitrarily chosen row from each group - 04-25-2007 , 03: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


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.