mwiggin1
01-27-2006, 04:09 PM
I have the following query:
SELECT DISTINCT t1.section_id, t1.section_descr, t1.page_number, t1.reviewed, t1.parent_id, t4.txt_entry, (SELECT MIN(actual_id) FROM dbo.ufn_GetParentSections(1800)) AS doc_grp_id FROM dbo.tblCCMContract t1 INNER JOIN dbo.jctCCMSectionWBS t2 ON t1.section_id = t2.section_id INNER JOIN dbo.tblCCMWBS t3 ON t2.wbs_id = t3.wbs_id LEFT OUTER JOIN dbo.tblCCMTxtEntries t4 ON t1.txt_entry_id = t4.txt_entry_id WHERE (t3.wbs_id = 29 OR t3.wbs_id = 21) ORDER BY parent_id
Which works fine with the literal value 1800. But when I do this:
SELECT DISTINCT t1.section_id, t1.section_descr, t1.page_number, t1.reviewed, t1.parent_id, t4.txt_entry, (SELECT MIN(actual_id) FROM dbo.ufn_GetParentSections(t1.section_id)) AS doc_grp_id FROM dbo.tblCCMContract t1 INNER JOIN dbo.jctCCMSectionWBS t2 ON t1.section_id = t2.section_id INNER JOIN dbo.tblCCMWBS t3 ON t2.wbs_id = t3.wbs_id LEFT OUTER JOIN dbo.tblCCMTxtEntries t4 ON t1.txt_entry_id = t4.txt_entry_id WHERE (t3.wbs_id = 29 OR t3.wbs_id = 21) ORDER BY parent_id
I get an error. Is there any way for me to pass t1.section_id to this function in a sub query?
SELECT DISTINCT t1.section_id, t1.section_descr, t1.page_number, t1.reviewed, t1.parent_id, t4.txt_entry, (SELECT MIN(actual_id) FROM dbo.ufn_GetParentSections(1800)) AS doc_grp_id FROM dbo.tblCCMContract t1 INNER JOIN dbo.jctCCMSectionWBS t2 ON t1.section_id = t2.section_id INNER JOIN dbo.tblCCMWBS t3 ON t2.wbs_id = t3.wbs_id LEFT OUTER JOIN dbo.tblCCMTxtEntries t4 ON t1.txt_entry_id = t4.txt_entry_id WHERE (t3.wbs_id = 29 OR t3.wbs_id = 21) ORDER BY parent_id
Which works fine with the literal value 1800. But when I do this:
SELECT DISTINCT t1.section_id, t1.section_descr, t1.page_number, t1.reviewed, t1.parent_id, t4.txt_entry, (SELECT MIN(actual_id) FROM dbo.ufn_GetParentSections(t1.section_id)) AS doc_grp_id FROM dbo.tblCCMContract t1 INNER JOIN dbo.jctCCMSectionWBS t2 ON t1.section_id = t2.section_id INNER JOIN dbo.tblCCMWBS t3 ON t2.wbs_id = t3.wbs_id LEFT OUTER JOIN dbo.tblCCMTxtEntries t4 ON t1.txt_entry_id = t4.txt_entry_id WHERE (t3.wbs_id = 29 OR t3.wbs_id = 21) ORDER BY parent_id
I get an error. Is there any way for me to pass t1.section_id to this function in a sub query?