Hi Guys,I'm new here hoping to contribute as much as i'm asking but my first one is a question.First off i consider myself a newbie when it comes to SQL as i've only been playing for it for a couple of months and i'm learning everyday so bear with me.My question is when you create more than one of what i refer to as a formula field (might be wrong) can you refer to each of them within the other formula field? Probably doesn't sound logical i know but let me give you an example.Here is just a small section of a select statement that i plan to turn into a stored proc.SELECT F_TASKS.TA_TASK_ID, F_RESOURCE.RES_NAME, FLOCATE.BG_SITE, FINFILE.IN_DESCRIPTION, F_TASKS.TA_CATEGORY, F_TASKS.TA_PRIORITY, F_TASK_TIME.TT_ID, F_TASK_TIME.TT_NAME, FINFILE.IN_DEC_HOURS, 'Next_SLA' = CASE WHEN (SELECT COUNT (*) FROM F_TASK_TIME WHERE TT_FKEY_TA_SEQ = F_TASKS.TA_SEQ and TT_FINISHED Is Not null ) >0 Then 'All SLAs Complete' WHEN (SELECT COUNT (*) FROM F_TASK_TIME WHERE TT_FKEY_TA_SEQ = F_TASKS.TA_SEQ and TT_CONTAINED Is Not null ) >0 Then 'Permanent Fix' WHEN (SELECT COUNT (*) FROM F_TASK_TIME WHERE TT_FKEY_TA_SEQ = F_TASKS.TA_SEQ and TT_STARTED Is Not null) >0 and F_TASKs.TA_PRIORITY = 'Priority 3' Then 'Permanent Fix' WHEN (SELECT COUNT (*) FROM F_TASK_TIME WHERE TT_FKEY_TA_SEQ = F_TASKS.TA_SEQ and TT_STARTED Is Not null) >0 and F_TASKs.TA_PRIORITY <> 'Priority 3' Then 'Temporary Fix' ELSE 'Investigate' END, 'Next Date' = CASE WHEN 'Next_SLA' = 'Permanent Fix' Then (SELECT TOP 1 TaskPerfSLAFixDate From SLA_TASK_PERFORMANCE WHERE TASKPERF_TA_SEQ = F_TASKS.TA_SEQ) ELSE '01/01/2001' END
Right the problem i have here is the 2nd "formula field" Next Date doesn't work as it's almost like it can't see the first formula field Next_SLA it just defaults to the 01/01/2001Any ideas, i've temporarily got aroudn this but instead of testing the result of the Next_SLA field doing the complete logical test from the first field again, which is lenghy and not very nice lol.