SQL/Mysql
[MYSQL]처음 생성된 데이터에 null값이 있는지 확인하는 쿼리
테이트
2022. 1. 17. 18:00
-- sampleTable : sampleZone(지역이름), sampleState(날씨상태), SampleDate(저장시각)
-- sampleState : '비', '눈', '맑음' 등 날씨를 저장
-- sampleState 상태값을 변경할 때마다 sampleTable에 저장
-- sampleZone이 처음 만들어진 데이터중 sampleState 값이 null인 데이터가 있는지 확인하는 쿼리
select *
from sampleTable a
inner join ( select sampleZone
, min(SampleDate) as SampleDate
from sampleTable group by sampleZone
) a on a.sampleZone = a.sampleZone
where a.nullCheck is null;