query

  • how can i select distinct records like...

     

    select a,b,c,d from emp where column c shud be distinct. 

  • I'm guessing...Hard to say without a little more info (such as sample data and sample expected results) :

    select a,b,c,d from emp

    inner join (select distinct c from emp) emp2 on emp2.c = emp.c

  • As Kim states, with this type of question it's best if you gave us sample data. Show us a few lines of data (sample) as it would be in the table. Then show us what result(s) you want based on that data.

    -SQLBill

  • If there are dupes on a,b, or d... whatcha wanna do?  Just grab anything?  Not exactly a good database practice but it helps to know before hand...

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • select emp_name,emp_email,class_date,

    class_name,emailsent from emp_details.

    kishore fdr@hotmail.com 2006-08-18 00:00:00.000 Tra N 

    kishore fdr@hotmail.com 2006-08-20 00:00:00.000 Tra N 

    here i need distinct class_date.

  • Okay. You have it. Those two dates ARE distinct.

    -SQLBill

  • I just gave 2 records..there are lot of records with dups

  • Like Bill said u have distinct dates. In your example what do u want the result to be?

  • The two records you provided are NOT duplicates. The dates are different.

    This is why we ask for sample data and what result you want based on that sample data.

    If you ask for distinct rows and you only provide us distinct rows...then you've got what you asked for.

    -SQLBill

Viewing 9 posts - 1 through 8 (of 8 total)

You must be logged in to reply to this topic. Login to reply