Sql 2000 Problem

  • i have a table.

    fields =

    1) Id

    2) name

    3) EmailId

    4) Age

    5) Salary

    now i want distinct recordsbased on name and EmailId then what should do me

  • select DISTINCT name, emailID from table

    ----------------------------------------------------------------------------------
    Your lack of planning does not constitute an emergency on my part...unless you're my manager...or a director and above...or a really loud-spoken end-user..All right - what was my emergency again?

  • this is right but i want to find out all fields whereas it gives only two field.

  • You may want to create a temp table and dump the data into that table and delete the duplicate rows using a cursor and fetch the data and display it to the end user.

    Because if you want to include all the columns you need to include them in group by or distinct and that would not yeild you what you are desiring to. Cursors are not recommended because of performance issues.

    Prasad Bhogadi
    www.inforaise.com

  • Give some example of what your data looks like, and on that data, how you wish to apply the 'distinct'..

    That is, indata, and expected output from that data.

    /Kenneth

  • you need to decide what aggregate you want for the other fields. If you want the highest age and salary for each name and email combination you could try this

    select max(id),name,email,max(salary),max(age) from table group by name,email


Viewing 6 posts - 1 through 5 (of 5 total)

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