• hi guys,

    thanks for your reply.

    On Sep 28, 8:29 am, deepak

    my requirement is i should getdistinctID ,i

    do not care about the other fields ,they may be decided by the where

    condition.let me make it more clear,

    lets say T1 has these data:

    ID name

    1 aaa

    2 bbb

    3 ccc

    4 ddd

    5 eee

    and T2 has

    ID FK name addr

    1 1 AAA CA

    2 1 AAA LA

    3 1 CCC CA

    4 2 DDD Ca

    5 2 EEE vegas

    if i have a where clause with T2.name=AAA,the whole query is something

    like this.

    with DistinctSelect as (

    selectdistinctid ,nameA,nameB,addr from vT1T2 --here i adding

    nameB ,which is a column in T2

    where nameB='AAA'

    ),

    SelectResult AS (

    select row_number() over(order by id) as rowno, id, nameA,nameB,addr

    -- nameB added

    from DistinctSelect

    )

    select * from SelectResult

    the results for the following quey will be

    rowno id nameA nameB addr

    1 1 aaa AAA CA

    2 1 aaa AAA LA

    so here id is notdistinct ,i am expecting my results to be somthing

    like this

    rowno id nameA nameB addr

    1 1 aaa AAA CA

    or

    rowno id nameA nameB addr

    1 1 aaa AAA LA

    hope i am clear , can i by any chance groupdistinctcolumns something

    like selectdistinct(id), nameA,nameB,addr from vt1t2.if i can some

    how achive grouping ofdistinct,then i think the problem is almost

    sloved.

    is there any way to work around it, could you please suggest.

    Thanks in Advance

    Deepak