Results 1 to 3 of 3
  1. #1
    TamworthBob is offline Novice
    Windows 10 Access 2010 64bit
    Join Date
    May 2020
    Posts
    21

    SQL using SELECT DISTINCT SELECTDISTINCTROOW

    How do I get only one example of a company name?





    SELECTDISTINCT tblStationData.StationID, tblStationData.[Station Name], tblRepReport.RepReportID
    FROM tblStationData INNERJOIN tblRepReport ON tblStationData.StationID = tblRepReport.StationID
    ORDERBY tblStationData.[Station Name];



    It needs to return the StationID

    The query is tied to a combo box

  2. #2
    TamworthBob is offline Novice
    Windows 10 Access 2010 64bit
    Join Date
    May 2020
    Posts
    21
    results:

  3. #3
    madpiet is offline Expert
    Windows 10 Office 365
    Join Date
    Feb 2023
    Posts
    565
    SELECTDISTINCT tblStationData.StationID, tblStationData.[Station Name], tblRepReport.RepReportID
    FROM tblStationData INNERJOIN tblRepReport ON tblStationData.StationID = tblRepReport.StationID
    ORDERBY tblStationData.[Station Name];

    The definition of the StationData and RepReport tables would help a LOT here. To answer your question though, if you don't need any values from the child table, you can use a pattern like this:

    SELECT <fields>
    FROM ParentTable p
    WHERE EXISTS (SELECT 1 FROM ChildTable c WHERE c.ParentRecordID = p.ParentRecordID )

    and you'll get one record for each Parent table record that has any child records in ChildTable. (incredibly imaginative names, right?)

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

Similar Threads

  1. Replies: 6
    Last Post: 05-05-2020, 11:21 PM
  2. Replies: 0
    Last Post: 02-11-2020, 08:12 PM
  3. Replies: 4
    Last Post: 12-14-2016, 05:20 PM
  4. Replies: 8
    Last Post: 04-21-2011, 05:29 PM
  5. SELECT DISTINCT not working
    By johnmerlino in forum Queries
    Replies: 2
    Last Post: 10-25-2010, 06:48 PM

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