--한달이내 마지막 접속일 조회

select b.col1,count(1) 

from table1 a

          left join 

          table2 b

          on a.col1 = b.col1

where  b.last_date between current_date-1 * interval '30 day' and current_date+1* interval '1 day'

 group by b.col1 

 order by col1

   limit 30; 

   

 

--특정기간 마지막 접속일 조회

select b.col1,count(1) 

from table1 a

          left join 

          table2 b

          on a.col1 = b.col1

where b.last_date between

'2021-01-01 00:00:00'  and '2021-01-01 00:00:00'

 group by b.col1 

 order by col1

   limit 30; 

   

+ Recent posts