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 id
s 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 id
s 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
Post a Comment