Subject: Use of "IF" in a ADP Stored Procedure
Posted By: Mickey123 Post Date: 12/5/2003 12:53:55 AM
Hi,

How would I be able to use CASE statement if it applies to different table.
For example: I have 3 tables, billing, Job_2 and JOB_COST_Query1_Sub

I want apply this CASE statement and extract some data from the third table: cost.
How would that be possibly be done ? Sounds complicated, isn't it?
Please help .....

Example:
-----------
SELECT dbo.billing.Job_No
FROM dbo.billing INNER JOIN
dbo.Job_2 ON dbo.billing.Job_No = dbo.Job_2.Job_No INNER JOIN
dbo.JOB_COST_Query1_Sub() JOB_COST_Query1_Sub ON dbo.Job_2.Job_No = JOB_COST_Query1_Sub.Job_No
WHERE (dbo.billing.Job_No = @JobNumber)

Have tried and modified the following query, but it didn't work, why?
SELECT dbo.billing.Job_No, dbo.JOB_COST_Query_Sub, CASE WHEN [CountAFE]>1 Then 'Multiple' Else [FirstOfAFE No],
FROM dbo.billing INNER JOIN
dbo.Job_2 ON dbo.billing.Job_No = dbo.Job_2.Job_No INNER JOIN
dbo.JOB_COST_Query1_Sub() JOB_COST_Query1_Sub ON dbo.Job_2.Job_No = JOB_COST_Query1_Sub.Job_No
WHERE (dbo.billing.Job_No = @JobNumber)



Thanks.




Go to topic 7235

Return to index page 992
Return to index page 991
Return to index page 990
Return to index page 989
Return to index page 988
Return to index page 987
Return to index page 986
Return to index page 985
Return to index page 984
Return to index page 983