I have a table where I use 'unused' to signify that a record is not yet
used. I want to know the number of unused records (but only if there are
unused records) and the total number of records.

At the moment I implemented it like:
SELECT   *
FROM     (
    SELECT   'Not used'  AS Type
    ,        COUNT(*)    AS NoUsed
    FROM     quotes
    WHERE    totalUsed == 'unused'
    UNION ALL
    SELECT   'Total'  AS Type
    ,        COUNT(*) AS NoUsed
    FROM     quotes
    )
WHERE    NoUsed > 0

Is this correct, or is there a better way?

-- 
Cecil Westerhof
_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to