Sorry for not responding sooner...unavoidably distracted...
Yes one firm has many calls records...
and you're looking for the time associated with the record of the LAST
call  you made to each firm.
Having obtained these "latest call" times for each FIRM
you then want to organise the firms in order of EARLIEST of those "latest
call" times first
i.e. the firm you called longest ago, first
I think your query does this and thank you very much for it


On 4 February 2013 14:25, Igor Tandetnik <i...@tandetnik.org> wrote:

> 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<http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users>
>
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to