Neil Toulouse
Programmer
Hi!
This I am sure is simple but is eluding me!!!
I have the following select statement which works fine and returns the correct data:
What I want to do is only bring back those records where 'session_count > 0'.
As you can see, session_count is derived from another select statement.
I cant use 'WHERE session_count > 0' as the field doesn't exist at that point.
Is this possible?
TIA
Neil
I like work. It fascinates me. I can sit and look at it for hours...
This I am sure is simple but is eluding me!!!
I have the following select statement which works fine and returns the correct data:
Code:
SELECT
so.[strategic_objective_id],
so.[name]'strategic_objective',
so.[description] 'objective description',
pso.[project_id],
p.[name] 'project_name',
session_count =( SELECT ISNULL(SUM(ISNULL(session_count,1)),0) FROM Sessions WHERE project_id = pso.project_id and start >= @start_date and start < @end_date + 1 ),
ISNULL([dbo].[udf_ECM_session_attendance_dates](pso.[project_id],@start_date,@end_date),0) AS 'total_attendance'
FROM dbo.strategic_objectives so
LEFT JOIN dbo.projects_strategic_objectives pso ON pso.[strategic_objective_id] = so.[strategic_objective_id]
LEFT JOIN [projects] p ON pso.[project_id] = p.[project_id]
WHERE so.active = 1
ORDER BY so.[strategic_objective_id],pso.[project_id]
What I want to do is only bring back those records where 'session_count > 0'.
As you can see, session_count is derived from another select statement.
I cant use 'WHERE session_count > 0' as the field doesn't exist at that point.
Is this possible?
TIA
Neil
I like work. It fascinates me. I can sit and look at it for hours...