Hello
Based on the below SQL statement, I am trying to only show the max order # (4) and the related last name, not all the last names.
DEFECTNUM MaxOfORDERNUM LastName
670 1 Dietz
670 2 Sandahl
670 4 Harig
I only want in my query to show the last name of "harig" as it is the highest order Number.
I have read many many postings on this site related to this but can't figure out how to get this to only show what I want (highest order number and related name). Note: this database is from an external application called Test Tracker, I pulled the tables in with ODBC links.
SELECT tbl_DefectsCarrie.DEFECTNUM, Max(tbl_DefectEvtsCarrie.ORDERNUM) AS MaxOfORDERNUM, tbl_CarrieUser.LastName
FROM tbl_DefectsCarrie INNER JOIN (tbl_CarrieUser INNER JOIN tbl_DefectEvtsCarrie ON tbl_CarrieUser.IDRecord = tbl_DefectEvtsCarrie.ASGNDUSERS) ON tbl_DefectsCarrie.IDRECORD = tbl_DefectEvtsCarrie.PARENTID
GROUP BY tbl_DefectsCarrie.DEFECTNUM, tbl_CarrieUser.LastName
HAVING (((tbl_DefectsCarrie.DEFECTNUM)=670))
ORDER BY Max(tbl_DefectEvtsCarrie.ORDERNUM);
Can anybody help me???![[banghead] [banghead] [banghead]](/data/assets/smilies/banghead.gif)
Thanks!
Based on the below SQL statement, I am trying to only show the max order # (4) and the related last name, not all the last names.
DEFECTNUM MaxOfORDERNUM LastName
670 1 Dietz
670 2 Sandahl
670 4 Harig
I only want in my query to show the last name of "harig" as it is the highest order Number.
I have read many many postings on this site related to this but can't figure out how to get this to only show what I want (highest order number and related name). Note: this database is from an external application called Test Tracker, I pulled the tables in with ODBC links.
SELECT tbl_DefectsCarrie.DEFECTNUM, Max(tbl_DefectEvtsCarrie.ORDERNUM) AS MaxOfORDERNUM, tbl_CarrieUser.LastName
FROM tbl_DefectsCarrie INNER JOIN (tbl_CarrieUser INNER JOIN tbl_DefectEvtsCarrie ON tbl_CarrieUser.IDRecord = tbl_DefectEvtsCarrie.ASGNDUSERS) ON tbl_DefectsCarrie.IDRECORD = tbl_DefectEvtsCarrie.PARENTID
GROUP BY tbl_DefectsCarrie.DEFECTNUM, tbl_CarrieUser.LastName
HAVING (((tbl_DefectsCarrie.DEFECTNUM)=670))
ORDER BY Max(tbl_DefectEvtsCarrie.ORDERNUM);
Can anybody help me???
![[banghead] [banghead] [banghead]](/data/assets/smilies/banghead.gif)
Thanks!