Jeff

> I guess I am having an off day with SQL. I think technically this should
> work but I get a syntax error
>
> UPDATE Account a
>
> SET a.last_update = (SELECT TOP 1 h.tranDate
>
>                      FROM History h
>
>                      WHERE a.Account_Number = h.Account_Number
>
>                      ORDER BY h.tranDate DESC)

I would think this is likely to give an error because there's no reason
syntactically why the subselect should return a single value - that "1"
could be any other number.

How about something like

UPDATE Account a

SET a.last_update = (SELECT max(h.tranDate)

                      FROM History h

                      WHERE a.Account_Number = h.Account_Number)

Nick
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]

Reply via email to