SQLite: Two different Counts on different table -
i pretty sure guys have simple , fast solution problem sql-skills limited , can't figure out self.
so have like:
newsgroup: [name(pk)]
article: [id(pk)] [newsgroupname (fk)] [date:date] [read:boolean]
what want know query gives me name of each newsgroup along count of unread articles, count of articles , date of recent one... possible archieve in single select-query?
thank guys in advance!
you can use appropriate aggregation functions:
select newsgroupname, sum(not read) countunread, count(*) countall, max(date) mostrecentdate article group newsgroupname;
Comments
Post a Comment