473,395 Members | 1,696 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Remove/omit duplicate records in MS Access Query result

2
This is the SQL code for starters.
Expand|Select|Wrap|Line Numbers
  1. SELECT DISTINCTROW [Qry_CRM_MNGT_150+_No_Action_NEW].CYCLE_DATE, [Qry_CRM_MNGT_150+_No_Action_NEW].SERIES_NBR, [Qry_CRM_MNGT_150+_No_Action_NEW].SERVICER_NBR, [Qry_CRM_MNGT_150+_No_Action_NEW].SERVICER_NAME, [Qry_CRM_MNGT_150+_No_Action_NEW].SERVICER_LOAN_NBR, [Qry_CRM_MNGT_150+_No_Action_NEW].LOAN_NBR, [Qry_CRM_MNGT_150+_No_Action_NEW].INTERNAL_LOAN_ID, [Qry_CRM_MNGT_150+_No_Action_NEW].ARCC_LOAN_NBR, [Qry_CRM_MNGT_150+_No_Action_NEW].LIEN_STATUS_CODE, [Qry_CRM_MNGT_150+_No_Action_NEW].MaxOfACTL_END_PRIN_BAL, [Qry_CRM_MNGT_150+_No_Action_NEW].REPORTED_ACTION_CODE, [Qry_CRM_MNGT_150+_No_Action_NEW].MONTHS_DELQ, IIf([COMMENT_CODE]="CX",[COMMENT_DATE_TIME],"") AS NEW_COMMENT_DATE_TIME, (IIf([COMMENT_CODE]="CX",[STAFF_NAME],"")) AS NEW_STAFF_NAME, (IIf([COMMENT_CODE]="CX",[COMMENT_TEXT],"")) AS NEW_COMMENT_TEXT, (IIf([COMMENT_CODE]="CX","CX","")) AS NEW_COMMENT_CODE
  2. FROM ([Qry_CRM_MNGT_150+_No_Action_NEW] LEFT JOIN MARS_COMMENTS_INFO ON [Qry_CRM_MNGT_150+_No_Action_NEW].INTERNAL_LOAN_ID = MARS_COMMENTS_INFO.INTERNAL_LOAN_ID) LEFT JOIN MARS_IFS_STAFF_INFO ON MARS_COMMENTS_INFO.COMMENT_AUTHOR = MARS_IFS_STAFF_INFO.INTERNAL_STAFF_LOGON
  3. GROUP BY [Qry_CRM_MNGT_150+_No_Action_NEW].CYCLE_DATE, [Qry_CRM_MNGT_150+_No_Action_NEW].SERIES_NBR, [Qry_CRM_MNGT_150+_No_Action_NEW].SERVICER_NBR, [Qry_CRM_MNGT_150+_No_Action_NEW].SERVICER_NAME, [Qry_CRM_MNGT_150+_No_Action_NEW].SERVICER_LOAN_NBR, [Qry_CRM_MNGT_150+_No_Action_NEW].LOAN_NBR, [Qry_CRM_MNGT_150+_No_Action_NEW].INTERNAL_LOAN_ID, [Qry_CRM_MNGT_150+_No_Action_NEW].ARCC_LOAN_NBR, [Qry_CRM_MNGT_150+_No_Action_NEW].LIEN_STATUS_CODE, [Qry_CRM_MNGT_150+_No_Action_NEW].MaxOfACTL_END_PRIN_BAL, [Qry_CRM_MNGT_150+_No_Action_NEW].REPORTED_ACTION_CODE, [Qry_CRM_MNGT_150+_No_Action_NEW].MONTHS_DELQ, IIf([COMMENT_CODE]="CX",[COMMENT_DATE_TIME],""), (IIf([COMMENT_CODE]="CX",[STAFF_NAME],"")), (IIf([COMMENT_CODE]="CX",[COMMENT_TEXT],"")), (IIf([COMMENT_CODE]="CX","CX","")); 



The purpose of this query is to identify the records that meet the specified parameters, with it's respective comment (s)if there is(are) any, and also the those records that have no comment (null) but meet the parameters. The problem I have is that for records that have a comment(s), and additional record shows up in the results with null comment value.

I am trying to figure out how I can eliminate the duplicate record with the Null comment value if that same record has a comment already showing in the results.
Oct 16 '08 #1
1 4874
nico5038
3,080 Expert 2GB
Looks to me you can have multiple comments.
If that's the case and one has a code <> CX it will add an empty row.

One solution is to use a groupby query to filter the comments (MARS_COMMENTS_INFO) for "CX" and select the comment of the MAX(COMMENT_DATE_TIME). (So first a groupby on INTERNAL_LOAN_ID with the MAX(COMMENT_DATE_TIME) for the "CX" comments and that query JOINED by INTERNAL_LOAN_ID and MAX(COMMENT_DATE_TIME) to get the (single) "CX" comment.
When the COMMENT_DATE_TIME is unique this will work, otherwise I would add also a MAX(COMMENT_TEXT).

Getting the idea ?

Nic;o)
Oct 24 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Schlauberger | last post by:
I am currently developing a VB.Net App that utilized an MS Access file to store the data. My Report data source is a Parameter Query in MS Access when the report loads the parameter is prompted...
1
by: Rado | last post by:
Hi All, This might quite simple process for some but I am finding it really difficult to do. What is required is not a standard Duplicate query but a variation on it. For example I have...
2
by: ms | last post by:
Access 2000: I am trying to delete duplicate records imported to a staging table leaving one of the duplicates to be imported into the live table. A unique record is based on a composite key of 3...
4
by: Andrew Chanter | last post by:
I have been working with an A97 database that performs a data processing function. It imports data from a flat text file then uses a dao transaction that executes a number of sql statements (about...
6
by: sara | last post by:
I have a procedure to automate bringing several Excel files into our Access tables, on a daily basis. The problem is that if the user has a problem, and tries to run the import again (maybe 3...
5
by: Manish | last post by:
The topic is related to MySQL database. Suppose a table "address" contains the following records ------------------------------------------------------- | name | address | phone |...
6
by: pooh80133 | last post by:
Hi! I am pasting my SQL code at the end of this message. I am trying to use SELECT DISTINCT in a query, but I am a beginner for using Access. Right now I have duplicate ID's (Indiv ID) in my...
2
by: nethravathy | last post by:
Hi, The following table namely elcbtripselect contains 5147 records.I want to know wether this table contains duplicate records or not. I tried with following query 1)SELECT...
0
by: BSB | last post by:
Hi, I generate a "Find Duplicate" query for one table that will return some records I want to capture those records in my VB code..... This is my code...pls guide me how to proceed.......
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.