[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Query outputting Unique Records

Posted on 2007-10-12
4
Medium Priority
?
185 Views
Last Modified: 2010-03-20
Hi,
I have a query which hopefully says find records where an SPN ID matches in both tbl_casbreaks and tbl_adequacy_list. Is there anyway to only to output all UNIQUE records that have an ID mtach instead of just all records, regardless if they are unique? Mu query at the moment is;

SELECT tbl_kyc_status.kyc_status_name, tbl_CasBreaks.spn_id, tbl_adequacy_list.spn_name_a, tbl_CasBreaks.Account_No, tbl_CasBreaks.Title, tbl_CasBreaks.Title2, tbl_CasBreaks.Field5, tbl_CasBreaks.Field6, tbl_CasBreaks.Field8, tbl_CasBreaks.Field9, tbl_CasBreaks.Field10, tbl_CasBreaks.Field11, tbl_CasBreaks.Field12, tbl_CasBreaks.Field13, tbl_CasBreaks.Field14
FROM tbl_kyc_status
INNER JOIN (tbl_CasBreaks INNER JOIN tbl_adequacy_list ON tbl_CasBreaks.spn_id = tbl_adequacy_list.spn_id) ON tbl_kyc_status.status_id = tbl_adequacy_list.kyc_statis_id
WHERE tbl_CasBreaks.spn_id =  tbl_adequacy_list.spn_id;
0
Comment
Question by:andyb7901
  • 2
  • 2
4 Comments
 
LVL 75

Expert Comment

by:Aneesh Retnakaran
ID: 20063879
did u try with 'DISTINCT '


SELECT DISTINCT tbl_kyc_status.kyc_status_name, tbl_CasBreaks.spn_id, tbl_adequacy_list.spn_name_a, tbl_CasBreaks.Account_No, tbl_CasBreaks.Title, tbl_CasBreaks.Title2, tbl_CasBreaks.Field5, tbl_CasBreaks.Field6, tbl_CasBreaks.Field8, tbl_CasBreaks.Field9, tbl_CasBreaks.Field10, tbl_CasBreaks.Field11, tbl_CasBreaks.Field12, tbl_CasBreaks.Field13, tbl_CasBreaks.Field14
FROM tbl_kyc_status
INNER JOIN (tbl_CasBreaks INNER JOIN tbl_adequacy_list ON tbl_CasBreaks.spn_id = tbl_adequacy_list.spn_id) ON tbl_kyc_status.status_id = tbl_adequacy_list.kyc_statis_id
WHERE tbl_CasBreaks.spn_id =  tbl_adequacy_list.spn_id;

0
 

Author Comment

by:andyb7901
ID: 20063909
I get the same number back. The ID has to be distinct? Can I use FIRST or something? Would that work? If so how would I do it?
0
 

Author Comment

by:andyb7901
ID: 20063933
Or maybe use a Group By? I dont know if this would help?
0
 
LVL 75

Accepted Solution

by:
Aneesh Retnakaran earned 2000 total points
ID: 20063958
SELECT  MIN(tbl_kyc_status.kyc_status_name)kyc_status_name ,
tbl_CasBreaks.spn_id,
MIN(tbl_adequacy_list.spn_name_a),
MIN(tbl_CasBreaks.Account_No),
MIN(tbl_CasBreaks.Title),
MIN(tbl_CasBreaks.Title2),
MIN(tbl_CasBreaks.Field5),
MIN(tbl_CasBreaks.Field6),
MIN(tbl_CasBreaks.Field8),
MIN(tbl_CasBreaks.Field9),
MIN(tbl_CasBreaks.Field10),
MIN(tbl_CasBreaks.Field11),
MIN(tbl_CasBreaks.Field12),
MIN(tbl_CasBreaks.Field13),
MIN(tbl_CasBreaks.Field14)
FROM tbl_kyc_status
INNER JOIN (tbl_CasBreaks INNER JOIN tbl_adequacy_list ON tbl_CasBreaks.spn_id = tbl_adequacy_list.spn_id) ON tbl_kyc_status.status_id = tbl_adequacy_list.kyc_statis_id
AND  tbl_CasBreaks.spn_id =  tbl_adequacy_list.spn_id
GROUP BY tbl_CasBreaks.spn_id , tbl_adequacy_list.spn_id
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Instead of error trapping or hard-coding for non-updateable fields when using QODBC, let VBA automatically disable them when forms open. This way, users can view but not change the data. Part 1 explained how to use schema tables to do this. Part 2 h…
If you’re using QODBC to update QuickBooks data from Microsoft® Access but Access is not showing the updated data, you could have set up QODBC incorrectly.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

872 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question