Selection Question

  • The post was cut off..

    I have a table that contains the key fields CustomerName and ItemDescription. I have some data that looks like the following:

     

    Customer                         ItemDescription

    John Doe                          Item1

    John Doe                          Item2

    John Doe                          Item3

    Jane Doe                          Item2

    Mike Doe                          Item3

    I need to be able to select the customer and item description, but only return one entry for each.

     

  • and the question is?

  • but only return one entry for each - for each what? Customer or ItemDescription?

    How do you determine which result you should get? Can you provide us what the result should look like? And your criteria.

    -SQLBill

  • My first thought is that you want only one unique Customer name. But if so, how do you determine which ItemDescription they should have?

    While you respond to that, this might give you an idea:

    SELECT DISTINCT Customer,

    MAX(ItemDescription) AS ItemDescription

    FROM tablename

    GROUP BY Customer

    -SQLBill

  • That statement was what I need. I did need to select a distinct customer name and the item description was based on a alphabetical list.

    So all I had to do was change the max to min and it worked great. Thanks

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

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