Computing.Net > Forums > Database > Problem with UNION query and DISTINCT

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Problem with UNION query and DISTINCT

Reply to Message Icon

Name: Tsuro
Date: June 11, 2009 at 17:04:14 Pacific
OS: Windows XP
Subcategory: General
Comment:

Hi,

I have the following UNION query in MS Access:

SELECT DISTINCT "DOM " & mDOMExceptions.ExceptionID as ExceptionID, mDOMExceptions.[Status], mDOMExceptions.[Date Created], mDOMExceptions.LastUpdate, sDOMExceptionComments.Date, sDOMExceptionComments.User, sDOMExceptionComments.Location, sDOMExceptionComments.Comment
FROM mDOMExceptions INNER JOIN sDOMExceptionComments ON mDOMExceptions.ExceptionID = sDOMExceptionComments.ExceptionID
UNION
SELECT DISTINCT "WOM " & mWOMExceptions.ExceptionID as ExceptionID, mWOMExceptions.[Status], mWOMExceptions.[Date Created], mWOMExceptions.LastUpdate, SWOMExceptionComments.Date, sWOMExceptionComments.User, sWOMExceptionComments.Location, sWOMExceptionComments.Comment
FROM mWOMExceptions INNER JOIN sWOMExceptionComments ON mWOMExceptions.ExceptionID = sWOMExceptionComments.ExceptionID;

I am trying to get a list of the "exceptions" but only showing their most recent comment.

When I run the query, I will get the following:

ExceptionID Status Date Created LastUpdate Date User Location Comment
WOM 52 Bring into Office 04.06.2009 04.06.2009 2:01:26 PM testUser1 Warehouse this item is missing its battery also
WOM 52 Bring into Office 04.06.2009 10.06.2009 2:24:11 PM testUser2 Office Please bring into office.



Sponsored Link
Ads by Google

Response Number 1
Name: Tsuro
Date: June 11, 2009 at 19:53:38 Pacific
Reply:

Problem solved


0

Response Number 2
Name: lowhanginghoney
Date: June 15, 2009 at 13:22:29 Pacific
Reply:

Great! Can you share the solution here so others can benefit from it? Please?

http://support.microsoft.com/default.aspx?scid=kb;en-us;555375
How to ask a question.


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More






Use following form to reply to current message:

Login or Register to Reply
LoginRegister


Sponsored links

Ads by Google


Results for: Problem with UNION query and DISTINCT

Problem with SQL query, php form www.computing.net/answers/dbase/problem-with-sql-query-php-form/169.html

Data synchronization between two offices www.computing.net/answers/dbase/data-synchronization-between-two-offices/712.html

Need help with SQL-query (access) www.computing.net/answers/dbase/need-help-with-sqlquery-access/209.html