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

Popular posts from this blog

html - How to set bootstrap input responsive width? -

javascript - Highchart x and y axes data from json -

javascript - Get js console.log as python variable in QWebView pyqt -