I have database dbadmin, table – tbl_empreimburse with fields-emp_id,rem_amount,rem_date.
I want to retrieve data which comes from given date to a week back.
I tried this query,
SELECT SUM(rem_amount),DATEADD(dd, -7, "2012-01-10")
FROM tbl_empreimburse
GROUP BY emp_id
HAVING emp_id='5' AND rem_date BETWEEN DATEADD(dd, -7, "2012-01-10") AND "2012-01-10"
It gives me error “FUNCTION dbadmin.DATEADD does not exist“. Do I need to convert “2012-01-10” to date format? Any Help, Please?
Check this *SQLFIDDLE reference out. 🙂
I am not sure why you are using
group byclause here…Sample date:
Query:
here is the query to get sum
Results:
all records by employee id = 5
sum of amount by employee id = 5