PDA

Click to See Complete Forum and Search --> : SQL Question


Negative0
Jun 26th, 2000, 03:00 AM
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.

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.



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

JHausmann
Jun 26th, 2000, 04:51 AM
6.5 likes:

SELECT DISTINCT(dbtName),* FROM myTable

Negative0
Jun 26th, 2000, 06:50 PM
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

Jun 26th, 2000, 09:34 PM
Probably this is clumsy but:

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

would select just the distinct rows.

JHausmann
Jun 26th, 2000, 11:09 PM
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).