Okay so the previous problem is solved but now I have a new issue. Say I want to add another column, to the second (derived table) based on the value in "Team_Status." This new column (call it "The_Date") would have a value from another query. I want to run code like this, but I'm not sure how the case stuff really works
Code:
SELECT Team_Num
, CASE WHEN MAX(status) = 'up'
THEN 'up'
ELSE 'down' END AS Team_Status
, CASE WHEN Team_Status = 'down'
THEN (SELECT someDate FROM someOtherTable WHERE Team_Num=this.Team_Num)
ELSE 'N/A' END AS The_Date
FROM daTable
GROUP
BY Team_Num
If doesn't make sense, please don't hesitate to ask for clarification.