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

networking - Vagrant-provisioned VirtualBox VM is not reachable from Ubuntu host -

c# - ASP.NET Core - There is already an object named 'AspNetRoles' in the database -

ruby on rails - ArgumentError: Missing host to link to! Please provide the :host parameter, set default_url_options[:host], or set :only_path to true -