I'm confused by the error message, "near 'order' : syntax error", with the
following statement.  The same statement, beginning with "select *" in
place of "delete", will function fine.

delete from seg_ny_adds
where needid = 90
order by prty desc
limit (select count() from seg_ny_adds where needid = 90) - 2

What I am trying to accomplish is to remove from each group (needid
identifies the group) all but the top 2 rows.
The plan is to loop through the table, identify each group that has more
than two rows, order them by priority descending,
and then delete the top records leaving the bottom two.  The bottom two
will be the highest priority rows.

Thanks for time and consideration,
dvn
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to