Results 1 to 3 of 3
  1. #1
    andy is offline Novice
    Windows XP Access 2003
    Join Date
    Feb 2011
    Posts
    1

    Querying unique record without using Distinct & GroupBy

    I am trying to retrieve unique records using select query. If I use Distinct or GroupBy funtion I am able to achieve the desired output, however I am not able to tick the check box (Reminded) when I run the query.
    I have table with data as follows,
    AuditID Date Reminded
    -----------------------------------------
    1203 01/01/2010 No
    1203 05/01/2010 No
    1204 06/01/2010 No
    1204 06/01/2010 No
    1204 07/01/2010 No
    1205 07/01/2010 No
    1206 06/01/2010 No
    1206 06/01/2010 No
    I want to achieve the following outout


    ---------------------------------------------
    Reminded AuditID Date
    ---------------------------------------------
    No 1203 05/01/2010
    No 1204 07/01/2010
    No 1205 07/01/2010
    No 1206 06/01/2010

    I am looking to retieve unique AuditID with the latest date.
    I tried the below queries
    select b.reminded,b.auditid from RiskActionPlan b where date=(select max(date) from RiskActionPlan where auditid=b.auditid)
    I am able to select the Reminded Checkbox when I run the above query however the it does NOT result with unique auditid (audit ids are repeted)
    If i add distinct (Select distinct ....) I am able to get the unique records but i am not able to check the Reminded checkbox.

    I have been trying to sort this out since last 4 hours, I will appreciate If someone could assist me with this.
    Thanks in advance.
    Andy

  2. #2
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,848
    Are you trying to set the value of Reminded to True/Yes for some condition?

  3. #3
    weekend00 is offline I may not be right
    Windows XP Access 2003
    Join Date
    Aug 2010
    Posts
    1,295
    you still need GROUP BY:
    select reminded,auditid,max([date]) from RiskActionPlan GROUP BY reminded,auditid

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Querying from a Query
    By jo15765 in forum Queries
    Replies: 11
    Last Post: 11-21-2010, 08:12 PM
  2. lost - linking date field based on a record with smaller Unique ID
    By stan.chernov@gmail.com in forum Queries
    Replies: 7
    Last Post: 09-16-2010, 02:22 PM
  3. Querying a password DB
    By blacksaibot in forum Programming
    Replies: 2
    Last Post: 05-20-2010, 10:37 AM
  4. Querying from 2 tables
    By egnaro in forum Queries
    Replies: 6
    Last Post: 01-28-2010, 06:30 PM
  5. Unique Record Identifier for MS SQL Server Tables
    By MGSP in forum Import/Export Data
    Replies: 2
    Last Post: 01-29-2006, 03:00 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums