Hi,

Try:

select * from table group by itemID order by name,Number DESC

Cheers,

Pieter

On 10/11/2013 20:09, John C wrote:

Hi all

Can anybody help me with the following query?

I have a table like:

*_ItemID             Name              Number_*

234 Washer            100

234 Washer            120

234 Washer            105

500 Nut                  520

500 Nut                  502

500 Nut                  501

What I would like to see is a for each ItemID the highest Number sorted by Name.

My sql is like:

*SELECT **

*FROM Table*

*GROUP BY ItemID*

*ORDER BY Name, Number*

What returns is:

*_ItemID             Name              Number_*

234             Washer            105

500 Nut                  501

It seems to return the last record for each item. How can I get the highest number for each Item?

Thanks a lot for any help.

John C



_______________________________________________
NZ Borland Developers Group - Delphi mailing list
Post: [email protected]
Admin: http://delphi.org.nz/mailman/listinfo/delphi
Unsubscribe: send an email to [email protected] with 
Subject: unsubscribe

_______________________________________________
NZ Borland Developers Group - Delphi mailing list
Post: [email protected]
Admin: http://delphi.org.nz/mailman/listinfo/delphi
Unsubscribe: send an email to [email protected] with 
Subject: unsubscribe

Reply via email to