On Fri, 6 May 2011, Matthew Jones wrote: > sqlite> create table a (a, b); > sqlite> insert into a values (10, 1); > sqlite> insert into a values (10, 2); > sqlite> insert into a values (10, 2); > sqlite> insert into a values (11, 2); > sqlite> insert into a values (11, 2); > sqlite> insert into a values (11, 3); > How can I do count equivalent of such a query to find out how many > distinct values of b there are for a given a? (That is get an answer of > 2 in the above)
select a, count(distinct b) from a group by a; or if you are checking a specific value of a: select count(distinct b) from a where a=10; Chris > > Thanks > > -- > Matthew Jones > Hewlett-Packard Ltd > Long Down Avenue > Stoke Gifford > Bristol. BS34 8QZ > Tel: +44 (0) 117 312 7490 > Email: matthew.jo...@hp.com<mailto:matthew.jo...@hp.com> > > Hewlett-Packard Limited registered Office: Cain Road, Bracknell, Berks, > RG12 1HN. Registered No: 690597 England > > The contents of this message and any attachments to it are confidential > and may be legally privileged. If you have received this message in > error, you should delete it from your system immediately and advise the > sender. > > To any recipient of this message within HP, unless otherwise stated you > should consider this message and attachments as "HP CONFIDENTIAL". > _______________________________________________ > sqlite-users mailing list > sqlite-users@sqlite.org > http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users > _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users