본문 바로가기

SQL/Mysql

[MYSQL]처음 생성된 데이터에 null값이 있는지 확인하는 쿼리

 

-- 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;

'SQL > Mysql' 카테고리의 다른 글

[MYSQL] 계정 생성 관리 및 권한 설정  (0) 2021.10.14
[MYSQL-SQL] 중복 데이터 조회  (0) 2021.10.08
[MYSQL] InnoDB VS MyISAM  (0) 2021.06.24