On 2/4/2013 2:40 AM, e-mail mgbg25171 wrote:
Your query is extremely close
but for the repetition of the c.ids at the end

I'm not sure I understand. What is the relationship of "firms" and "calls" tables? Is it one-to-many (multiple calls for each firm)? If so, what is the meaning of calls.last? Are you updating this field for all calls for a firm whenever a new call is inserted?

Perhaps you are looking for something like this:

select f.id from firms f left join calls c on (f.id = c.firm_id)
group by f.id order by min(c.last);

--
Igor Tandetnik

_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to