We help IT Professionals succeed at work.

Not getting unique records

sam2929
sam2929 asked
on
I have values like
id         date          code
0001      20110729123425      aaa
0001      20110729205634      aaa

i just want to pick up last date to make record distict

i am doing

select max(date) ,id, code from table aa
group by id.code


it should give me distinct
0001      20110729205634      aaa but i getting both records

date is chracter 14

Comment
Watch Question

Aaron TomoskyDirector, SD-WAN Solutions
CERTIFIED EXPERT

Commented:
select max(date) ,id, code from table aa
group by id, code

Unless your . Was a mistype
CERTIFIED EXPERT
Commented:
i have tested on SAS9.2 but not getting the problem you mentioned...

data X;
id="0001";date="20110729123425";code="aaa";output;
id="0001";date="20110729205634";code="aaa";output;
run;

proc sql;
      create table y as
      select max(date), id, code from x
      group by id,code;
quit;

output:
                                          The SAS System      

                                                    id    code
                                    --------------------------
                                    20110729205634  0001  aaa




Explore More ContentExplore courses, solutions, and other research materials related to this topic.