SQL Query - TechRepublic
Question
January 17, 2008 at 08:11 AM
rheal.dugas

SQL Query

by rheal.dugas . Updated 18 years, 5 months ago

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)

This discussion is locked

All Comments