Hi Simon,
Assume you have a following data:
matchNo, year, month
34 2007 9
27 2006 5
26 2006 5
24 2005 4
For the above data my answer should be 3, since there are three unique
combination of year, month {(2007, 9), (2006, 5), (2005, 4)}. Here I
need to find the number of distinct combinations of year, month not the
count for a particular year, month.
Regards,
Phani
-----Original Message-----
From: Simon Davies [mailto:[EMAIL PROTECTED]
Sent: Tuesday, September 25, 2007 3:14 PM
To: [email protected]
Subject: Re: [sqlite] select COUNT (DISTINCT column1, column2) from
table?
On 25/09/2007, B V, Phanisekhar <[EMAIL PROTECTED]> wrote:
.
.
> Assume you have a following data:
>
> matchNo, year, month
>
> 34 2007 9
>
> 27 2006 5
>
> 26 2006 5
>
> Now distinct year, month will return
>
> 2007, 9
>
> 2006, 5
>
> Is there a way by which I can count (distinct year, month)
combinations?
> For this example answer should be 2.
>
> Regards,
>
> Phani
Hi Phani,
SQLite version 3.4.2
Enter ".help" for instructions
sqlite>
sqlite> create table m( mNo integer, year integer, month integer );
sqlite>
sqlite> insert into m values (1, 2006, 11 );
sqlite> insert into m values (2, 2007, 5 );
sqlite> insert into m values (3, 2007, 5 );
sqlite>
sqlite> select count(*), year, month from m group by year,month;
1|2006|11
2|2007|5
sqlite>
Rgds,
Simon
------------------------------------------------------------------------
-----
To unsubscribe, send email to [EMAIL PROTECTED]
------------------------------------------------------------------------
-----
-----------------------------------------------------------------------------
To unsubscribe, send email to [EMAIL PROTECTED]
-----------------------------------------------------------------------------