mysql - group by while getting the Ids of the columns that meet the condition -


i wanted write this

select min(date),        id     test    t.site_id=site_id    group site_id 

but not possible ids after group call.

then came this

select t.id    test t   t.date in(select min(date)                     test                    t.site_id=site_id                    group site_id) 

this select supposed me ids of test rows have same date minimum date each site there anyway make simpler ?

try

select t1.id  test t1 inner join (    select site_id, min(date) mdate    test    group site_id ) t2 on t1.site_id = t2.site_id , t1.date = t2.mdate 

Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -