I am using the following query to get the results which i demonstrated
SELECT
b.sales_title,c.cat_name,COUNT(b.sales_id) as cnt,COUNT(DISTINCT e.comment_id) as coun
FROM tb_sale_report a
INNER JOIN tbl_sales b on a.sales_id=b.sales_id
INNER JOIN tb_category c on c.cat_id=b.category_id
LEFT JOIN tb_comment e on b.sales_id=e.sales_id
GROUP BY b.sales_title
+------------+---------+--------+------+
| sales_title | cat_name| cnt | coun |
+-------------+---------+--------+------+
| My Sales |Toys |20 |5 |
| First Sale |Dress |28 |1 |
|Premium |Computer |7 |16 |
+-------------+--------+---------+------+
Now in the table tb_sale_report i am also having another field named view_date which will store the date in which the record id added. Now i am planning to add a filtering option to the table tb_search_report in which the user can search the records added in between particular dates such as a start date and an end date. How can i write the where condition to filter the results as per the dates specified.
Need help.Thanks in advance.
Try below :
Pleae replace start_date and end_date with values