Hi folks,I wonder if I can get help with the code below.I created two views one as a subquery and the other using that subquery to produce the final results. However, I'd like to create one view rather than two views for the final results. I'm not sure where to put the subquery.Here's the first part:(this is the subquery used in the Main query, it's called vSumOfHoursSub)SELECT Hours, JobCode, TimeLineDate, EmployeeId FROM time.TimeLines WHERE (NOT (JobCode LIKE '90001'))
I created a View with that and used it with the View below:SELECT TOP (100) PERCENT DATEADD(wk, DATEDIFF(wk, 0, time.vSumOfHoursSub.TimeLineDate), 5) AS WeekEnding, time.Employees.Employee, SUM(time.vSumOfHoursSub.Hours) AS SumOfHours FROM time.Employees LEFT OUTER JOIN time.vSumOfHoursSub ON time.Employees.EmployeeId = time.vSumOfHoursSub.EmployeeId GROUP BY DATEADD(wk, DATEDIFF(wk, 0, time.vSumOfHoursSub.TimeLineDate), 5), time.Employees.Employee
As you can see, I omit the value 90001 from the results by using the first view. I want to be able to use the first query directly in the Main View. I just don't know how to do this.Does anyone have any ideas that could help me?Thanks again.:)