[TriLUG] Any SQL gurus willing to help?
Andrew Perrin
clists at perrin.socsci.unc.edu
Mon Dec 17 14:01:18 EST 2007
Ah-hah - I figured it out, bulding on William Sutton's suggestion:
ncsboe=# create view final_times as select phone_num, max(attempt_when)
from attempts group by phone_num;
CREATE VIEW
ncsboe=# update attempts set final = true where att_id in (select att_id
from attempts left join final_times on attempts.phone_num =
final_times.phone_num and attempts.attempt_when = final_times.max
where max is not null);
UPDATE 25000
Not the prettiest, but it appears to work.
Thanks,
Andy
----------------------------------------------------------------------
Andrew J Perrin - andrew_perrin (at) unc.edu - http://perrin.socsci.unc.edu
Associate Professor of Sociology; Book Review Editor, _Social Forces_
University of North Carolina - CB#3210, Chapel Hill, NC 27599-3210 USA
More information about the TriLUG
mailing list