Try putting a column name for the two calculated
fields as SQL server does not know what to call them in the
#temptable:
select
field1,
field2,
...... ,
max(smalldatetime1) as Maxdate1, /* or min */
max(smalldatetime2) as Maxdate2 /* or min */
into
#temptable
from
tablename
group by field1, field2, .....
Hope this helps,
Chris Dukes