group by - Get only 1st duplicate record oracle -


i have tables , use "inner join" on these tables. want unique data values duplicated. result table. can't uniqe names because of dates different. used distinct, group no chance.

    hsb.name    hmb.date     --------    -------------------     michael     15.04.2013 07:55:08     madonna     15.04.2013 10:58:17     madonna     15.04.2013 11:05:46     terry       15.04.2013 11:13:39     britney     15.04.2013 11:52:00     slash       15.04.2013 11:55:39     slash       15.04.2013 11:56:10 

and sql ->

     select hsb.name, hmb.date       hsb hsb              inner join hmb hmb      on hsb.hsb_no = hmb.hmb_no      , hsb.hsb_g_no = hmb.hmb_g_no      hsb.hsb_kod = '&kod'      , hsb.hsb_date >= '&date1'      , hsb.hsb_date < '&date2' 

please try:

select name,     date from(     select          hsb.name,          hmb.date,         row_number() on (partition hsb.name order hmb.date) rnum      hsb hsb inner join hmb hmb on hsb.hsb_no = hmb.hmb_no         , hsb.hsb_g_no = hmb.hmb_g_no               hsb.hsb_kod = '&kod' ,          hsb.hsb_date >= '&date1' ,          hsb.hsb_date < '&date2' )x rnum=1 

Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -