Query outputting Unique Records

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;
andyb7901Asked:
Who is Participating?
 
Aneesh RetnakaranConnect With a Mentor Database AdministratorCommented:
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
 
Aneesh RetnakaranDatabase AdministratorCommented:
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
 
andyb7901Author Commented:
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
 
andyb7901Author Commented:
Or maybe use a Group By? I dont know if this would help?
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.