Re: MAX select problem

2005-07-29 Thread Philippe Poelvoorde

Lee Denny wrote:

Hello,

I'm trying to get the date and amount of the most visits to my site over a
given time period using :

SELECT max(visits) as maximum FROM visit WHERE (((visit_date >=
'$sdatestring') and (visit_date < '$edatestring')) and (site_id=$site_id))

This gives me the right figure, but when I try to pull out the date that
this occured on with,

SELECT max(visits) as maximum, visit_date FROM visit WHERE (((visit_date >=
'$sdatestring') and (visit_date < '$edatestring')) and (site_id=$site_id))
GROUP BY visit_date

I get a completely different and wrong answer,

any ideas?

Cheers,

Lee




I think that :
http://dev.mysql.com/doc/mysql/en/example-maximum-row.html
would answer you question more than I ;)


--
Philippe Poelvoorde
COS Trading Ltd.

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]



Re: MAX select problem

2005-07-29 Thread Jigal van Hemert

Lee Denny wrote:

Hello,

I'm trying to get the date and amount of the most visits to my site over a
given time period using :

SELECT max(visits) as maximum FROM visit WHERE (((visit_date >=
'$sdatestring') and (visit_date < '$edatestring')) and (site_id=$site_id))

This gives me the right figure, but when I try to pull out the date that
this occured on with,


SELECT * FROM visit WHERE (((visit_date >=
 '$sdatestring') and (visit_date < '$edatestring')) and 
(site_id=$site_id)) ORDER BY visits DESC LIMIT 1;


Regards, Jigal.

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]



MAX select problem

2005-07-29 Thread Lee Denny
Hello,

I'm trying to get the date and amount of the most visits to my site over a
given time period using :

SELECT max(visits) as maximum FROM visit WHERE (((visit_date >=
'$sdatestring') and (visit_date < '$edatestring')) and (site_id=$site_id))

This gives me the right figure, but when I try to pull out the date that
this occured on with,

SELECT max(visits) as maximum, visit_date FROM visit WHERE (((visit_date >=
'$sdatestring') and (visit_date < '$edatestring')) and (site_id=$site_id))
GROUP BY visit_date

I get a completely different and wrong answer,

any ideas?

Cheers,

Lee


-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]