Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DISTINCT function 1

Status
Not open for further replies.

Lost500

IS-IT--Management
Joined
Mar 10, 2009
Messages
110
Location
US
Hi all,
I am trying to just get unique values in my query. however when i use the DISTINCT function in the query i get an error saying one or more of the fields are not comparable. i do have a unique ID field can i place the function somewhere else in the query or use something else to just look at the ID field and return just the unique records? any help would be great.
 
What is the SQL code raising the error ?

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
The code is:
SELECT DISTINCT fieldname, fieldname, ect.
FROM Tablename INNER JOIN Tablename ect.


I am sure that I have a memo field in here but is there any way to use the Unique id field to get rid of duplicates and still include the fields i want in my query? Thaks for the help
 
the pseudo SQL isn't what we'd like to see, we'd really like to see the ACTUAL SQL....additionally it would be helpful if you gave us some sample data and your expected results.

Thanks,

Leslie

Have you met Hardy Heron?
 
thanks dhookom! I think i'll try to convert all my memo fields any advice as to what to convert them to?
 
You don't need to change your table structure unless you really only need to store less than 256 characters. If this is the case, change the field to TEXT 255. If you need to store more than 255 characters, as I stated, you can use the Left() function to change the appearance of the value so that you can use DISTINCT or GROUP BY.

Duane
Hook'D on Access
MS Access MVP
 
Thanks dhookom but i get the error, [Microsoft][ODBC SQL Serber Driver][SQL Server]Argument data type ntext is invalid for argument 1 of left function. (#8116), any advice?
 
It is a MDB and a regular query.
 
Since you probably want to open this read-only, I would create a pass-through query with SQL like:
Code:
SELECT DISTINCT [info_id]
       ,Convert(VarChar(255),[minutes]) as Minutes
      ,[create_dte]
      ,[create_by]
      ,[apprv_dte]
      ,[apprv_by]
      ,[post_dte]
      ,[post_by]
      ,[Team]
      ,[MeetDate]
  FROM [meeting_minutes]
You could enter a number up to nearly 8000 depending on the number of characters in other fields.

Duane
Hook'D on Access
MS Access MVP
 
thanks dhookom. worked great!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top