Both Igor's and Simon's solutions work on my test system.

The only additional comment is that Simon's works in Sqlite as expected.
However running the same on PostgreSQL bombs with an error complaining
about an sub-query with no name! Interesting? Perhaps watch out for
portability with that one. Igor's 'select count(distinct)' worked on both
without problem and returned the same results.


On 18 February 2016 at 22:14, Simon Slavin <slavins at bigfraud.org> wrote:

>
> On 18 Feb 2016, at 5:42am, <admin at shuling.net> <admin at shuling.net> 
> wrote:
>
> > Then I want to obtain the total count of unique values for F1 field. In
> the
> > above sample, since unique F1 field values are 1, 2, 3 and 4, so the
> count
> > is 4. How to write SQL query to obtain the value?
>
> First, get a list of the unique values:
>
> SELECT F1 FROM MyTable GROUP BY F1
>
> then count them
>
> SELECT count(*) FROM (SELECT F1 FROM MyTable GROUP BY F1)
>
> The above code is just from my head.  I have not tested it.
>
> Simon.
> _______________________________________________
> sqlite-users mailing list
> sqlite-users at mailinglists.sqlite.org
> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
>



-- 
Regards,
     Michael.j.Falconer.

Reply via email to