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!

Query Help

Status
Not open for further replies.

JazzMaan

Programmer
Jun 15, 2004
57
US
i have 2 tables:
Individual: has iid, hid (Individual id, household id)
Order_header: iid, order amount

I want the query to return 1 individual per household who has the hightest order amoount

 
Hi!

Try something like this:
Code:
SELECT TOP 1 i.[iid], i.[hid], o.[order amount]
FROM [Individual] AS i INNER JOIN [Order_header] AS o
ON i.[iid] = o.[iid]
ORDER BY o.[order amount] DESC;

Cheers,
MakeItSo

[navy]"We had to turn off that service to comply with the CDA Bill."[/navy]
- The Bastard Operator From Hell
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top