Let me first apologize for what is probably a very easy solution, but I'm new to SQL and our IT dept is swamped, therefore I left to try to do this on my own. Here goes:
I'm trying to create a view that I can then use to build a Crystal Report. I have a dept of nurses that approve medical procedures called decisions. I'm trying to count the number of decisions a nurse does per day. The problem is I'm trying to convert a date time field to just a date field as I do not need the time portion. What happens is the time is 00:00:00.000 but it still is grouping by time. A nurse should have one entry appear per date. Here is a copy of my select statement:
SELECT decision_by, (convert(datetime,convert(varchar(12),final_decision_date))) AS Final_Decision_date, (count(treatment_decision_key)) as CompletedReviews
FROM tbl_treatment_decision
WHERE year(final_decision_date)=2004
GROUP BY decision_by, final_decision_date
ORDER BY decision_by ASC, final_decision_date ASC
GO
I also need to create a field that counts the number of days worked in a month. (Running total that resets at the beginning of the next month)
Here is a sample of what my result set is:
decision_by final_decision_date completedreviews
aharris 2004-09-27 00:00:00.000 1
aharris 2004-09-27 00:00:00.000 1
aharris 2004-09-27 00:00:00.000 1
aharris 2004-09-27 00:00:00.000 1
This should read:
aharris 2004-09-27 4
I haven't made it to the running total yet (Daysworked in the month) I was trying to get the datetime conversion working first.
Thanks for any help you can give.
Lowell
I'm trying to create a view that I can then use to build a Crystal Report. I have a dept of nurses that approve medical procedures called decisions. I'm trying to count the number of decisions a nurse does per day. The problem is I'm trying to convert a date time field to just a date field as I do not need the time portion. What happens is the time is 00:00:00.000 but it still is grouping by time. A nurse should have one entry appear per date. Here is a copy of my select statement:
SELECT decision_by, (convert(datetime,convert(varchar(12),final_decision_date))) AS Final_Decision_date, (count(treatment_decision_key)) as CompletedReviews
FROM tbl_treatment_decision
WHERE year(final_decision_date)=2004
GROUP BY decision_by, final_decision_date
ORDER BY decision_by ASC, final_decision_date ASC
GO
I also need to create a field that counts the number of days worked in a month. (Running total that resets at the beginning of the next month)
Here is a sample of what my result set is:
decision_by final_decision_date completedreviews
aharris 2004-09-27 00:00:00.000 1
aharris 2004-09-27 00:00:00.000 1
aharris 2004-09-27 00:00:00.000 1
aharris 2004-09-27 00:00:00.000 1
This should read:
aharris 2004-09-27 4
I haven't made it to the running total yet (Daysworked in the month) I was trying to get the datetime conversion working first.
Thanks for any help you can give.
Lowell