2011-02-10 23 views
5

Benim tablo yapısı benmaksimum sayım

Sorgu

select count(open_date) as c,day(open_date) as d 
from link_click 
where month(open_date)="01" and year(open_date)="2011" 
group by d 
having c =MAX(c); 

ama öyle bir ayın belirli bir gününde recored tıklamaları max sorgulamak istiyorum

| Field  | Type  | Null | Key | Default   | Extra | 
| uid  | char(255) | NO |  |     |  | 
| lid  | char(255) | NO | MUL |     |  | 
| ip_address | char(15) | NO |  |     |  | 
| user_agent | char(255) | YES |  | NULL    |  | 
| open_date | timestamp | NO | MUL | CURRENT_TIMESTAMP |  | 
| referrer | char(255) | YES |  | NULL    |  | 
| environ | text  | YES |  | NULL    |  | 
| country | char(255) | NO | MUL |     |  | 

olduğunu sonuçlanan boş küme.

Pls. önermek.

+3

Bu IM değil, kendi satırına her cümle ya maddesini koymak gerekmez. – BoltClock

cevap

3

Bundan sonra mı bu?

select count(open_date) as c,day(open_date) as d 
from link_click 
where month(open_date)="01" and year(open_date)="2011" 
group by d 
order by c desc 
limit 1; 
+0

"GROUP BY DATE (zaman damgası)" seçeneğine ihtiyacınız olduğunu düşünüyorum. – Bobby

+0

@Bobby bu d 'grubu değil mi? d olarak – JohnC

+0

mysql> select count (open_date) c, gün (open_date) -> den -> link_click -> nereye -> ay (open_date) = "01" ve yılı (open_date) = "2011" -> c tarafından sınır sırasına göre grup> 1; – soumen

0

Bu işe yarayabilecek:

select * from (
    select count(open_date) as c,day(open_date) as d 
    from link_click 
    where month(open_date)="01" and year(open_date)="2011" 
    group by d) 
having c =MAX(c); 
+0

mysql> select count (open_date) c, gün (open_date) -> den -> link_click -> nereye -> ay (open_date) = "01" ve yılı (open_date) = "2011" -> c tarafından sınır sırasına göre grup> 1; – soumen

+0

Bununla ne demek istiyorsun? İşaretledim ve yorumunuzu ** JohnC ** 'nin yanıtına eşit buldu. Bu onun cevabının sizin için çalıştığı anlamına mı geliyor? Eğer öyleyse, cevabını, cevabının solundaki büyük onay işaretini tıklatarak kabul etmelisiniz. – awe