1
오늘의 고객 수를 시 오늘, 어제, 지난 주, 지난 달로 계산하고 싶습니다.지난 1 주간, 지난 1 개월간, 어제의 필드 수를 얻는 방법
나는 나는 다음과 같은
고객처럼
c_id city_id c_name currentdate
1 1 Rama 2015-01-30 09:43:17
2 1 kavitha 2015-04-30 09:43:17
도시
city_id city_name
1 hyd
2 Wgl
난 다음에 그것을 시도를 내 테이블 구조가
city today yesterday lastweek lastmnth
1 23 2 12 12
같은 결과합니다. 이와 유사하게
select c.c_city, (select count(cr_id) as lastmonth from customer
where currentdate > DATE(NOW() - INTERVAL 30 DAY))) from customers as c
left join cities as ci on c.city_id = ci.city_id group by c.city_id
감사합니다. 매우 도움이됩니다. –