▶ join사용하지 않고 windows함수를 사용해 max_date 셀렉트하기
SELECT group,MAX(date) as max_date
FROM table
WHERE checks>0
GROUP BY group
That works to get the max date..join it back to your data to get the other columns:
Select group,max_date,checks
from table t
inner join
(SELECT group,MAX(date) as max_date
FROM table
WHERE checks>0
GROUP BY group)a
on a.group = t.group and a.max_date = date
https://stackoverflow.com/questions/19432913/select-info-from-table-where-row-has-max-date
▶ default
defaul
▶ default
defaul
▶ default
defaul
▶ default
defaul
▶ default
defaul
▶ default
defaul
▶ default
defaul
▶ default
defaul
▶ default
defaul
▶ default
defaul
▶ default
defaul
▶ default
defaul
▶ default
defaul
▶ default
defaul
▶ default
defaul
▶ default
defaul
▶ default
defaul
▶ default
defaul
▶ default
defaul
▶ default
defaul
'DataBase > SQL Basic' 카테고리의 다른 글
Inner join, outer join, left join, right join (0) | 2020.02.19 |
---|