How about 

        SELECT TOP 1 ID_ENC_TOY_IMAGE, ENC_TOY_IMAGE_LINK_TEXT
        FROM ENC_TOY_IMAGE
        WHERE ID_ENC_TOY = #ID_ENC_TOY#
        ORDER BY ID_ENC_TOY_IMAGE DESC

--K

> -----Original Message-----
> From: Mark Warrick [mailto:[EMAIL PROTECTED]]
> Sent: Friday, September 22, 2000 1:28 AM
> To: CF-Talk
> Subject: SQL Select Max + a column
> 
> 
> I'm trying to do this:
> 
>       SELECT ID_ENC_TOY_IMAGE, ENC_TOY_IMAGE_LINK_TEXT
>       FROM ENC_TOY_IMAGE
>       WHERE ID_ENC_TOY = #ID_ENC_TOY#
> 
> But I want the max ID_ENC_TOY_IMAGE row.
> 
> I've tried:
> 
>       SELECT max (ID_ENC_TOY_IMAGE) as maxid, ENC_TOY_IMAGE_LINK_TEXT
>       FROM ENC_TOY_IMAGE
>       WHERE ID_ENC_TOY = #ID_ENC_TOY#
> 
> But I get an aggregate error.
> 
> If I leave off the extra column it works fine, but of course 
> then I'd have to run another query to get the remaining info I need.
> 
> I could also select all records and then order them in 
> descending order by ID_ENC_TOY_IMAGE, but that seems like an 
> awful waste of processor power.
> 
> Anyone know how to do this the right way?
> 
> --------------------------------------------------------------
> Mark Warrick
> Phone: (714) 547-5386
> Efax.com Fax: (801) 730-7289
> Personal Email: [EMAIL PROTECTED]
> Personal URL: http://www.warrick.net 
> Business Email: [EMAIL PROTECTED]
> Business URL: http://www.fusioneers.com
> ICQ: 346566
> --------------------------------------------------------------
> 
> --------------------------------------------------------------
> ----------------
> Archives: http://www.mail-archive.com/[email protected]/
> To Unsubscribe visit 
> http://www.houseoffusion.com/index.cfm?sidebar=lists&body=list
s/cf_talk or send a message to [EMAIL PROTECTED] with
'unsubscribe' in the body.
------------------------------------------------------------------------------
Archives: http://www.mail-archive.com/[email protected]/
To Unsubscribe visit 
http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/cf_talk or send a 
message to [EMAIL PROTECTED] with 'unsubscribe' in the body.

Reply via email to