Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

select max brings back more than 1 row... 1

Status
Not open for further replies.

Sniipe

Programmer
Oct 9, 2006
115
IE
I have this code:

Code:
Select max(a.templateid) as templateid, a.questionid,  a.ANSWER, a.quoteid 
from PPT_Answer A, PPT_Question Q 
where A.QUESTIONID = Q.questionID 
and A.templateid = Q.templateid 
AND A.QuoteID='TCA0136327' 
and a.answercell = 'B15'
group by a.questionid, a.answer, a.quoteid
unfortunately it sometimes brings back more than 1 row for example:
Code:
TEMPLATEID	QUESTIONID					ANSWER	QUOTEID
532			EndPointsSingleLinePhonesIP	10		TCA0136327
545			EndPointsSingleLinePhonesIP	9		TCA0136327

I only want the row with the highest templateid brought back, which is what I thought max(a.templateid) would do?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top