Question Locked

SQL Query

0 helpful
3 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

I have a database table with the following fields.
Log_ID Number AND log_age_days (time to close in days)

I want to be able to create a view that will count the logs that were close First Day log_age_days =0
Second Day log_age_days =1 and so on up to 7 day and more if needed
I have it working for log_age_days = 0. Just need to know how to add the others to the same view. Below is the working query for log_age_days = 0

SELECT { fn MONTH(dbo.SOLUTIONIMPORTED$.create_date) } AS Expr1, COUNT(dbo.SOLUTIONIMPORTED$.log_id) AS Expr2,
dbo.SOLUTIONIMPORTED$.log_age_days
FROM dbo.SOLUTIONIMPORTED$ INNER JOIN
dbo.Employee_Information ON dbo.SOLUTIONIMPORTED$.own_emp_no = dbo.Employee_Information.Employee_Number
WHERE ({ fn YEAR(dbo.SOLUTIONIMPORTED$.create_date) } = 2007)
GROUP BY { fn MONTH(dbo.SOLUTIONIMPORTED$.create_date) }, dbo.SOLUTIONIMPORTED$.log_age_days
HAVING ({ fn MONTH(dbo.SOLUTIONIMPORTED$.create_date) } = 12) AND (dbo.SOLUTIONIMPORTED$.log_age_days = 0)

3 replies

by phishphood13

If you remove "AND (dbo.SOLUTIONIMPORTED$.log_age_days = 0)" wouldn't the Select statement bring back a row for each value of the column log_age_days where create_date was during 12/2007?

by rheal.dugas

That was the easiest thing I have ever done.
Thank You very much.

This discussion is closed to new replies.