Awesome... And no CTE. General over complications and over thinking and tunnel-visioned on my part. I just had to tag on whatever sort order I want, and voila. Appreciated.
Now I'll have to use USING a bit more often to get the drift and get out of this multi-call thing. I sort of see what is going on here, but practice is whats needed. Thanks again! On Mon, Mar 7, 2016 at 9:56 PM, Igor Tandetnik <igor at tandetnik.org> wrote: > On 3/7/2016 9:47 PM, Stephen Chrzanowski wrote: > >> Currently my application makes two queries to the database. One to get >> the >> list of projects via [ select ProjectID,Description from Projects order by >> Description ] >> >> It then goes through each record retrieved and then gets another query via >> [ select (select count(VideoID) from vViewedVideos where DateViewed is >> null >> and ProjectID=:P) Unwatched, (select count(VideoID) from vViewedVideos >> where ProjectID=:P) Videos ] where :P is the ProjectID. >> > > > select ProjectID, Description, > sum(VideoID is not null and DateViewed is null) Unwatched, > count(VideoID) Videos > from Projects left join vViewedVideos using (ProjectID) > group by ProjectID; > > -- > Igor Tandetnik > > _______________________________________________ > sqlite-users mailing list > sqlite-users at mailinglists.sqlite.org > http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users >

