mysql - How to add date condition to my query? -
i have sql statement. works, , need add 1 condition. need sort date. occurence - date row.
select dd.caption, count(t.occurence) transaction t inner join dict_departments dd on dd.id = t.terminal_id group dd.caption how add condition:
where t.occurence between (current_date() - interval 1 month) to query.
between requires 2 arguments, start point , end point. if end point current time, have 2 options:
- using
between:
where t.occurence between (current_date() - interval 1 month) , now()
- using simple comparison operator:
where t.occurence >= (current_date() - interval 1 month)
Comments
Post a Comment