how to get distinct values in the following scenarion
am 06.02.2010 11:57:50 von MuraliKrishna
------=_NextPart_000_0000_01CAA749.56EE27E0
Content-Type: text/plain;
charset="us-ascii"
Content-Transfer-Encoding: 7bit
Hi
I have table like as following..
Cust_id
Visited_date
1
2-1-2010
2
3-1-2010
3
4-1-2010
4
5-1-2010
6
6-1-2010
1
7-1-2010
2
8-1-2010
These visitor ids with visited date. but I want only all the customers with
first visited date.
Please help me in this..
Regards
Muralikrishna
------=_NextPart_000_0000_01CAA749.56EE27E0--
Re: how to get distinct values in the following scenarion
am 08.02.2010 20:07:02 von Shawn Green
MuraliKrishna wrote:
> Hi
>
> I have table like as following..
>
>
>
>
> Cust_id
>
> Visited_date
>
>
> 1
>
> 2-1-2010
>
>
> 2
>
> 3-1-2010
>
>
> 3
>
> 4-1-2010
>
>
> 4
>
> 5-1-2010
>
>
> 6
>
> 6-1-2010
>
>
> 1
>
> 7-1-2010
>
>
> 2
>
> 8-1-2010
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> These visitor ids with visited date. but I want only all the customers with
> first visited date.
>
> Please help me in this..
>
So you want to see only the earliest date for each visitor? Try a query
that looks like this:
SELECT visitor_id, min(visit_date) from ... GROUP BY visitor_id;
The details behind this kind of query are available from many, many
sources. Here's one from our manual:
http://dev.mysql.com/doc/refman/5.1/en/counting-rows.html
(in your case, you are using MIN() instead of COUNT() )
The full list of GROUP BY Functions are here:
http://dev.mysql.com/doc/refman/5.1/en/group-by-functions-an d-modifiers.html
--
Shawn Green, MySQL Senior Support Engineer
Sun Microsystems, Inc.
Office: Blountville, TN
--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/mysql?unsub=gcdmg-mysql-2@m.gmane.org