Hi, I have a select statement that gets data from one table and I have part of the main select constructed of selects on another table to get counts and return it in the same data set.
If you look at the commented out portions in each of the internal selects, I'd like to make the "@p_PROJECTID" equal to the value of the [ProjectID] I'm selecting just above it. Can I do this, or do I need a new statement?
Thanks,
James
Code:
SELECT
P.intProjectID [ProjectID],
P.strProjectName [Name],
...
COUNT_GOOD = (SELECT COUNT(*) [Good] FROM tblProjectMilestone WHERE
--int_fk_ProjectID = @p_PROJECTID
strMilestoneStatus = 'GOOD'),
COUNT_CAUTION = (SELECT COUNT(*) [Good] FROM tblProjectMilestone WHERE
--int_fk_ProjectID = @p_PROJECTID
strMilestoneStatus = 'CAUTION'),
COUNT_DANGER = (SELECT COUNT(*) [Good] FROM tblProjectMilestone WHERE
--int_fk_ProjectID = @p_PROJECTID
strMilestoneStatus = 'DANGER')
--select the resources too and dates
FROM tblProject AS P ...
If you look at the commented out portions in each of the internal selects, I'd like to make the "@p_PROJECTID" equal to the value of the [ProjectID] I'm selecting just above it. Can I do this, or do I need a new statement?
Thanks,
James