mercredi 9 mars 2016

How do you count all of the values in a column that satisfy your condition? (sqlite)

I have a table that contains the number of workers in a set of different job fields, in all of the wards in the country. How can you find the number of wards that have more than x amount of workers (across all job fields)? My current query looks like this:

SELECT
  (SELECT COUNT(1) FROM Table WHERE
    (SELECT SUM(working) FROM Table GROUP BY table.ward) > x)
AS working FROM Table;

Aucun commentaire:

Enregistrer un commentaire