Q:

How do I optimize a "latest sales" sql query? 

This query has become my nemesis over the past few years because I've never found a way to optimize it.  Now my nemesis becomes your nemesis! :) 
Consider the following table:
create table Sales (
  SaleId int identity(1,1) primary key,
  SalesmanId int not null,
  Amount smallmoney not null
)

For the sake of argument, assume that this table has 10^100 rows (business is brisk) and therefore a table scan is out of the question. 
Now we want to determine the SaleId of each salesman's most recent sale.  Simple enough, right?  Here is the query for that:
select
  SalesmanId,
  max(SaleId) SaleId
from Sales
group by Sales. SalesmanId

When we run this query the query optimizer does a full table scan, which is expected because it has no way of knowing where each salesman's sales fall within the table.  So let's help it out by adding the following index:
create unique nonclustered index IX_Sales on Sales
(
  SalesmanId asc,
  SaleId asc
)

Now it should be trivial (for a human, anyway) to find the most recent values because we use the values of the first column of the index to identify all possible salesmen and the last entries of the second column to locate each salesman's latest sale.  Unfortunately, the query optimizer still does an index seek over the entire index (all 10^100 rows) in this case, so it takes just as long. 
Interestingly, if we write the query to find the latest sale for a given salesman,
select max(SaleId)
from Sales
where SalesmanId = 1

the query optimizer uses an index seek on IX_Sales and gets it with one row of I/O. Even without IX_Sales, it does a clustered index scan that somehow gets it in one row of I/O (maybe using the table statistics?).  But if we modify this to
select max(SaleId)
from Sales
where SalesmanId = 1
group by SalesmanId

or
select max(SaleId)
from Sales
group by SalesmanId
having SalesmanId = 1

we're back to a high row-count index seek over lots of rows (although less than if you'd omitted the filter altogether, again probably due to statistics). 
So ... any ideas on how I could defeat my nemesis? 
Update
Some have suggested joining against a table of possible SalesmanId values, like so
select Latest.* 
from
(
  select 
    SalesmanId,
    max(SaleId) SaleId
  from Sales
  group by SalesmanId
) Latest
inner join Salesmen on 
  Salesmen. SalesmanId = Latest. SalesmanId

I tested this idea but the query optimizer still chooses to do a full table scan. 

A:

Here is a solution that takes a similar approach as your cursor solution. 
SELECT
   salesmanId, 
   (SELECT MAX(saleid) FROM sales WHERE salesmanid = salesmen.salesmanId) AS MaxSaleId
FROM salesmen

The execution plan shows that it is using a seek on the sales table.