DATE_FORMAT(변환시킬값, '변환하고싶은날짜형식의 양식')
* 대소문자 예민
MYSQL VER.
select DATE_FORMAT(consulting_date,'%Y-%m') as yearMonth, count(consulting_date) as studentCount from consulting
join student on student_id=student_consulting_id
where consulting_deletion="N" and teacher_student_id="49"
and consulting_date like "2021%"
group by DATE_FORMAT(consulting_date,'%Y-%m')
order by yearMonth asc;
MAPPER VER.
**mapper에 넣을때 like concat(#{thisYear},"%")
-concat으로 이어붙여쓰기!!!!!!
<select id="getPerConsultingInfo" resultType="kr.portfolio.forfree.vo.DataVO">
select DATE_FORMAT(consulting_date,"%Y-%m") as yearMonth, count(consulting_date) as studentCount from consulting
join student on student_id=student_consulting_id
where consulting_deletion="N" and teacher_student_id=#{teacher_id} and consulting_date like concat(#{thisYear},"%")
group by DATE_FORMAT(consulting_date,"%Y-%m")
order by yearMonth asc;
</select>
'괴발개발 > Spring Framework' 카테고리의 다른 글
forfree메모 (0) | 2021.10.01 |
---|---|
브라우저에 스크롤 만들기 (0) | 2021.10.01 |
DB_ (mysql, mapper)시간차이, 시간합계, 중복제거 (0) | 2021.09.30 |
형변환시키기 (0) | 2021.09.30 |
특정부분만 새로고침 시키기 (0) | 2021.09.30 |