Results 1 to 5 of 5

Thread: SQL Question

  1. #1

    Thread Starter
    PowerPoster 2.0 Negative0's Avatar
    Join Date
    Jun 2000
    Location
    Southeastern MI
    Posts
    4,367

    Question

    Here is a problem I am trying to solve:

    I have a set of data, and I am trying to grab the data with the most recent changes made to it using a date reference. My problem is that the distinct will only let me get one field, which is not my unique ID field. I need to be able to get all of the data for each row but only get the unique rows.

    Code:
    SELECT DISTINCT dbtNAME FROM myTAble
    This code gets the two records but only retrieves the field named dbtNAME and I need all of the columns.



    Code:
    SELECT DISTINCT dbtName,* FROM myTable
    This code grabs all records from myTable


    I am using SQL 7.0, VB 5.0, and ADO 2.1

    Thanks in advnace

  2. #2
    Frenzied Member
    Join Date
    Aug 1999
    Location
    Santa Clara, Ca , 95058
    Posts
    1,105
    6.5 likes:

    SELECT DISTINCT(dbtName),* FROM myTable


  3. #3

    Thread Starter
    PowerPoster 2.0 Negative0's Avatar
    Join Date
    Jun 2000
    Location
    Southeastern MI
    Posts
    4,367
    SELECT DISTINCT(dbtName),* FROM myTable
    I have already tried this and the DISTINCT command also runs on the * so it returns all of the records.

    Thanks anyways

  4. #4
    Guest
    Probably this is clumsy but:

    select distinct(col1 + col2), col1, col2 from tablename

    would select just the distinct rows.

  5. #5
    Frenzied Member
    Join Date
    Aug 1999
    Location
    Santa Clara, Ca , 95058
    Posts
    1,105
    Originally posted by Negative0
    SELECT DISTINCT(dbtName),* FROM myTable
    I have already tried this and the DISTINCT command also runs on the * so it returns all of the records.

    Thanks anyways
    Then 7.0 works differently than 6.5 because an equivalent statement returns one row per unique item, in my case (although I'm not sure it always returns the row I want).

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width